{"_id":"@alexrr2iggs/ssr","_rev":"2-fd278af2489ec336ea0e5a2d969ab536","name":"@alexrr2iggs/ssr","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@alexrr2iggs/ssr","version":"1.0.0","author":"","license":"ISC","_id":"@alexrr2iggs/ssr@1.0.0","maintainers":[{"name":"alexrr2iggs","email":"alexandru.bunduche@yahoo.com"}],"homepage":"https://github.com/bitBeater/ssr#readme","bugs":{"url":"https://github.com/bitBeater/ssr/issues"},"dist":{"shasum":"3e03bd1b19908f2cedbdb18eb0f72f471dcf0802","tarball":"https://registry.npmjs.org/@alexrr2iggs/ssr/-/ssr-1.0.0.tgz","fileCount":38,"integrity":"sha512-E1KwEkf3r8wUnSm49M5ODJJTwdtOI0do2FdFhYiwXmCUSD8FD9UARgpqDdEiIQlFjupzC9hIplpKPdpa5q2F9A==","signatures":[{"sig":"MEUCIGYhL3fd5brBFF1/24eaRVohmKzczTneJ4UdD3sxDSLLAiEAtrpgxE62v4LZq8IpVYtwaIL990JzlZjnNbU6K5psJZU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24715},"main":"dist/index.js","types":"./dist/index.d.ts","gitHead":"af8dcb68ec155c2beea0511b0e9d77810d2a3cea","private":false,"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexrr2iggs","email":"alexandru.bunduche@yahoo.com"},"repository":{"url":"git+https://github.com/bitBeater/ssr.git","type":"git"},"_npmVersion":"10.9.0","description":"Tiny TypeScript typings to describe search filters, selected fields, ordering, and pagination for repositories. It’s runtime-agnostic (ORM/DB/framework independent) and focuses on strong compile-time safety for your query shape.","directories":{},"_nodeVersion":"22.12.0","dependencies":{"type-fest":"^2.14.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ssr_1.0.0_1757425823054_0.4470305096497649","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@alexrr2iggs/ssr","version":"2.0.0","description":"Tiny TypeScript typings to describe search filters, selected fields, ordering, and pagination for repositories. It’s runtime-agnostic (ORM/DB/framework independent) and focuses on strong compile-time safety for your query shape.","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"default":"./dist/index.js"}},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"repository":{"type":"git","url":"git+https://github.com/bitBeater/ssr.git"},"scripts":{"test":"tsc && tsc --noEmit ./tests/valid_types.ts && node --test -r ./node_modules/ts-node/register/transpile-only.js ./tests/**/*"},"author":"","license":"ISC","devDependencies":{"@types/node":"^24.3.1","type-fest":"^2.14.0","ts-node":"^10.9.2"},"_id":"@alexrr2iggs/ssr@2.0.0","gitHead":"07638799c6d43999b3e3c70138b944f977cdd7c2","bugs":{"url":"https://github.com/bitBeater/ssr/issues"},"homepage":"https://github.com/bitBeater/ssr#readme","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-SHKlHqwtaioxMoctTQjRL0pi/dWVqLVrvmIZGzdcsbn/OFmwTg2IlvoOWo2PnXKCj2fMrWjqxXvHLoKfRkZN3Q==","shasum":"9fe9e8dd6c4aa8c340f16aee2ddc9cce2355122f","tarball":"https://registry.npmjs.org/@alexrr2iggs/ssr/-/ssr-2.0.0.tgz","fileCount":34,"unpackedSize":22765,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIA8n1FrhgrY0ekTTM4RnLdi6HwS/8WsAYTdYwkAzmKkXAiB/UH/HyJr9AMcTZvm6kP2oQD50Je1+JT8/xj0v/jKWMA=="}]},"_npmUser":{"name":"alexrr2iggs","email":"alexandru.bunduche@yahoo.com"},"directories":{},"maintainers":[{"name":"alexrr2iggs","email":"alexandru.bunduche@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ssr_2.0.0_1757498096836_0.5283948642509768"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-09T13:50:22.979Z","modified":"2025-09-10T09:54:57.187Z","1.0.0":"2025-09-09T13:50:23.245Z","2.0.0":"2025-09-10T09:54:57.016Z"},"bugs":{"url":"https://github.com/bitBeater/ssr/issues"},"license":"ISC","homepage":"https://github.com/bitBeater/ssr#readme","repository":{"type":"git","url":"git+https://github.com/bitBeater/ssr.git"},"description":"Tiny TypeScript typings to describe search filters, selected fields, ordering, and pagination for repositories. It’s runtime-agnostic (ORM/DB/framework independent) and focuses on strong compile-time safety for your query shape.","maintainers":[{"name":"alexrr2iggs","email":"alexandru.bunduche@yahoo.com"}],"readme":"## @bitbeater/ssr — Type-safe search, fields, order, and pagination\n\nTiny TypeScript typings to describe search filters, selected fields, ordering, and pagination for repositories. It’s runtime-agnostic (ORM/DB/framework independent) and focuses on strong compile-time safety for your query shape.\n\nKey ideas:\n- Search: deep, type-safe filters with operators (equal, like, greater, lesser, between, not)\n- Fields: precise field selection, including nested objects and arrays\n- Order: multi-field ordering with direction, nulls handling, and priority\n- Pagination: page + pageSize with optional search/order/fields\n- Repository: a minimal interface to wire your data source\n\n\n## Install\n\n```bash\nnpm i @bitbeater/ssr\n```\n\n\n## Quick start\n\n```ts\nimport {\n\tFields,\n\tOrder,\n\tPaginatedResult,\n\tPaginatedSearch,\n\tRepository,\n\tSearch,\n} from '@bitbeater/ssr';\n```\n\n\n## Person model used in examples\n\nIncludes number, string, object, date, array, and boolean types.\n\n```ts\ntype Contact = {\n\ttype: 'email' | 'phone';\n\tvalue: string;\n\tverified: boolean;\n};\n\ntype Person = {\n\tid: number;            // number\n\tname: string;          // string\n\tage: number;           // number\n\tisActive: boolean;     // boolean\n\tcreatedAt: Date;       // date\n\ttags: string[];        // array of scalar\n\taddress: {             // object\n\t\tcity: string;\n\t\tzip: number;\n\t};\n\tcontacts: Contact[];   // array of objects\n\tnotes?: string | null; // nullable field\n};\n```\n\n\n## Search — type-safe filters\n\nOperator shape for scalar fields:\n- equal: T | T[]\n- like: T\n- range: { greater: T; lesser: T }\n- not?: boolean (negate any of the above)\n\nYou can pass either a raw scalar (shorthand for equal) or a Find<T> object with one operator. Nested objects and arrays are supported recursively.\n\n```ts\nimport { Search } from '@bitbeater/ssr';\n\nconst search: Search<Person> = {\n\t// scalars\n\tname: { like: 'ali' },\n\tage: { greater: 18 },\n\tisActive: true, // shorthand for { equal: true }\n\tcreatedAt: {  greater: new Date('2024-01-01'), lesser: new Date('2024-12-31') },\n\t// array of scalars -> filter by an element match\n\ttags: { like: 'script' },\n\t// or shorthand equal\n\t// tags: 'typescript',\n\n\t// nested object\n\taddress: {\n\t\tcity: { like: 'York' },\n\t},\n\n\t// array of objects -> filter by fields on the element type\n\tcontacts: {\n\t\tverified: { equal: true },\n\t\ttype: { equal: ['email', 'phone'] },\n\t},\n};\n```\n\nNotes:\n- Arrays use the element type for filtering (semantics like “any element matches” are up to your implementation).\n- Functions are excluded by design and cannot be filtered.\n - Nullable fields are treated as their non-nullable type for filtering (i.e., `string | null` is filtered as `string`). If you need explicit null checks, model them in your repository implementation or extend the types to support it.\n\n\n## Fields — shape the returned data\n\nRules:\n- true includes the field\n- object selects nested fields recursively\n- arrays accept either true (whole element) or a nested object describing the element shape\n- functions are excluded\n\n```ts\nimport { Fields } from '@bitbeater/ssr';\n\nconst fields: Fields<Person> = {\n\tid: true,\n\tname: true,\n\taddress: { city: true },\n\ttags: true, // include array values\n\tcontacts: { type: true, verified: true },\n\t// Omitting a key excludes it (unless the root is set to true)\n};\n```\n\n\n## Order — multi-field ordering\n\nEach ordered field accepts a strategy:\n- direction: 'ASC' | 'DESC'\n- nulls?: 'FIRST' | 'LAST'\n- priority?: number (lower number = higher precedence)\n\n```ts\nimport { Order } from '@bitbeater/ssr';\n\nconst order: Order<Person> = {\n\tcreatedAt: { direction: 'DESC', nulls: 'LAST', priority: 1 },\n\tname: { direction: 'ASC', priority: 2 },\n\t// order within arrays-of-objects is expressed over the element type\n\tcontacts: { verified: { direction: 'DESC', priority: 1 } },\n};\n```\n\n\n## PaginatedSearch and PaginatedResult\n\n```ts\nimport { PaginatedSearch, PaginatedResult } from '@bitbeater/ssr';\n\nconst query: PaginatedSearch<Person> = {\n\tpage: 0,        // default 0\n\tpageSize: 20,   // omit to fetch until the end\n\tfields,         // optional: return all when omitted/empty\n\torder,          // optional\n\tsearch,         // optional: match-all when omitted\n};\n\n// Your data source returns this shape\nconst result: PaginatedResult<Person> = {\n\tpage: 0,\n\tpageSize: 20,\n\ttotalCount: 2,\n\titems: [/* persons */],\n};\n```\n\n\n## Repository interface\n\nBring your own persistence. These types describe a minimal repo surface.\n\n```ts\nimport { Repository } from '@bitbeater/ssr';\n\nconst peopleRepo: Repository<Person> = {\n\tsave: async (people) => people, // create/update\n\tsearch: async (q) => ({ page: q?.page ?? 0, pageSize: q?.pageSize, totalCount: 0, items: [] }),\n\tremove: async (s) => [],\n};\n```\n\n\n## Type-only package\n\nThis library exports TypeScript types with no runtime. Use them to type your query-building and repository contracts in any stack (SQL, NoSQL, REST, GraphQL, ORM, etc.).\n\n\n## API surface\n\n- Fields<T>: describe selected fields\n- Search<T>: describe filters by field with operators\n- Order<T>: describe ordering with direction/nulls/priority\n- PaginatedSearch<T>: page, pageSize, order, fields, search\n- PaginatedResult<T>: page, pageSize, totalCount, items\n- Repository<T>: save, search, remove function types\n\n\n## License\n\nISC\n","readmeFilename":"README.md"}