dyno-table 0.2.0-0 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +182 -577
  2. package/dist/{table.cjs → index.cjs} +175 -87
  3. package/dist/index.d.cts +2971 -0
  4. package/dist/index.d.ts +2971 -0
  5. package/dist/{table.js → index.js} +127 -86
  6. package/package.json +10 -77
  7. package/dist/builder-types-C_PDZhnP.d.ts +0 -118
  8. package/dist/builder-types-DtwbqMeF.d.cts +0 -118
  9. package/dist/builders/condition-check-builder.cjs +0 -394
  10. package/dist/builders/condition-check-builder.cjs.map +0 -1
  11. package/dist/builders/condition-check-builder.d.cts +0 -157
  12. package/dist/builders/condition-check-builder.d.ts +0 -157
  13. package/dist/builders/condition-check-builder.js +0 -392
  14. package/dist/builders/condition-check-builder.js.map +0 -1
  15. package/dist/builders/delete-builder.cjs +0 -405
  16. package/dist/builders/delete-builder.cjs.map +0 -1
  17. package/dist/builders/delete-builder.d.cts +0 -166
  18. package/dist/builders/delete-builder.d.ts +0 -166
  19. package/dist/builders/delete-builder.js +0 -403
  20. package/dist/builders/delete-builder.js.map +0 -1
  21. package/dist/builders/paginator.cjs +0 -199
  22. package/dist/builders/paginator.cjs.map +0 -1
  23. package/dist/builders/paginator.d.cts +0 -179
  24. package/dist/builders/paginator.d.ts +0 -179
  25. package/dist/builders/paginator.js +0 -197
  26. package/dist/builders/paginator.js.map +0 -1
  27. package/dist/builders/put-builder.cjs +0 -476
  28. package/dist/builders/put-builder.cjs.map +0 -1
  29. package/dist/builders/put-builder.d.cts +0 -274
  30. package/dist/builders/put-builder.d.ts +0 -274
  31. package/dist/builders/put-builder.js +0 -474
  32. package/dist/builders/put-builder.js.map +0 -1
  33. package/dist/builders/query-builder.cjs +0 -674
  34. package/dist/builders/query-builder.cjs.map +0 -1
  35. package/dist/builders/query-builder.d.cts +0 -6
  36. package/dist/builders/query-builder.d.ts +0 -6
  37. package/dist/builders/query-builder.js +0 -672
  38. package/dist/builders/query-builder.js.map +0 -1
  39. package/dist/builders/transaction-builder.cjs +0 -894
  40. package/dist/builders/transaction-builder.cjs.map +0 -1
  41. package/dist/builders/transaction-builder.d.cts +0 -511
  42. package/dist/builders/transaction-builder.d.ts +0 -511
  43. package/dist/builders/transaction-builder.js +0 -892
  44. package/dist/builders/transaction-builder.js.map +0 -1
  45. package/dist/builders/update-builder.cjs +0 -627
  46. package/dist/builders/update-builder.cjs.map +0 -1
  47. package/dist/builders/update-builder.d.cts +0 -365
  48. package/dist/builders/update-builder.d.ts +0 -365
  49. package/dist/builders/update-builder.js +0 -625
  50. package/dist/builders/update-builder.js.map +0 -1
  51. package/dist/conditions--ld9a78i.d.ts +0 -331
  52. package/dist/conditions-ChhQWd6z.d.cts +0 -331
  53. package/dist/conditions.cjs +0 -59
  54. package/dist/conditions.cjs.map +0 -1
  55. package/dist/conditions.d.cts +0 -3
  56. package/dist/conditions.d.ts +0 -3
  57. package/dist/conditions.js +0 -43
  58. package/dist/conditions.js.map +0 -1
  59. package/dist/entity.cjs +0 -228
  60. package/dist/entity.cjs.map +0 -1
  61. package/dist/entity.d.cts +0 -149
  62. package/dist/entity.d.ts +0 -149
  63. package/dist/entity.js +0 -224
  64. package/dist/entity.js.map +0 -1
  65. package/dist/query-builder-Csror9Iu.d.ts +0 -507
  66. package/dist/query-builder-D2FM9rsu.d.cts +0 -507
  67. package/dist/standard-schema.cjs +0 -4
  68. package/dist/standard-schema.cjs.map +0 -1
  69. package/dist/standard-schema.d.cts +0 -57
  70. package/dist/standard-schema.d.ts +0 -57
  71. package/dist/standard-schema.js +0 -3
  72. package/dist/standard-schema.js.map +0 -1
  73. package/dist/table-BEhBPy2G.d.cts +0 -364
  74. package/dist/table-BW3cmUqr.d.ts +0 -364
  75. package/dist/table.cjs.map +0 -1
  76. package/dist/table.d.cts +0 -12
  77. package/dist/table.d.ts +0 -12
  78. package/dist/table.js.map +0 -1
  79. package/dist/types.cjs +0 -4
  80. package/dist/types.cjs.map +0 -1
  81. package/dist/types.d.cts +0 -22
  82. package/dist/types.d.ts +0 -22
  83. package/dist/types.js +0 -3
  84. package/dist/types.js.map +0 -1
  85. package/dist/utils/partition-key-template.cjs +0 -19
  86. package/dist/utils/partition-key-template.cjs.map +0 -1
  87. package/dist/utils/partition-key-template.d.cts +0 -32
  88. package/dist/utils/partition-key-template.d.ts +0 -32
  89. package/dist/utils/partition-key-template.js +0 -17
  90. package/dist/utils/partition-key-template.js.map +0 -1
  91. package/dist/utils/sort-key-template.cjs +0 -19
  92. package/dist/utils/sort-key-template.cjs.map +0 -1
  93. package/dist/utils/sort-key-template.d.cts +0 -35
  94. package/dist/utils/sort-key-template.d.ts +0 -35
  95. package/dist/utils/sort-key-template.js +0 -17
  96. package/dist/utils/sort-key-template.js.map +0 -1
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- // src/utils/partition-key-template.ts
4
- function partitionKey(strings, ...keys) {
5
- return (params) => {
6
- let result = strings[0] ?? "";
7
- for (let i = 0; i < keys.length; i++) {
8
- const key = keys[i];
9
- if (key) {
10
- result += params[key] + (strings[i + 1] ?? "");
11
- }
12
- }
13
- return result;
14
- };
15
- }
16
-
17
- exports.partitionKey = partitionKey;
18
- //# sourceMappingURL=partition-key-template.cjs.map
19
- //# sourceMappingURL=partition-key-template.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/partition-key-template.ts"],"names":[],"mappings":";;;AA8BO,SAAS,YAAA,CACd,YACG,IACwC,EAAA;AAC3C,EAAA,OAAO,CAAC,MAAW,KAAA;AACjB,IAAI,IAAA,MAAA,GAAS,OAAQ,CAAA,CAAC,CAAK,IAAA,EAAA;AAE3B,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CAAK,EAAA,EAAA;AACpC,MAAM,MAAA,GAAA,GAAM,KAAK,CAAC,CAAA;AAClB,MAAA,IAAI,GAAK,EAAA;AACP,QAAA,MAAA,IAAU,OAAO,GAAgB,CAAA,IAAK,OAAQ,CAAA,CAAA,GAAI,CAAC,CAAK,IAAA,EAAA,CAAA;AAAA;AAC1D;AAGF,IAAO,OAAA,MAAA;AAAA,GACT;AACF","file":"partition-key-template.cjs","sourcesContent":["export type StrictGenerateType<T extends readonly string[]> = {\n [K in T[number]]: string;\n};\n\n/**\n * Creates a template function for generating DynamoDB partition keys with dynamic values.\n * Use this function when you need to:\n * - Create consistent partition key patterns with variable parts\n * - Generate partition keys that follow a specific format\n * - Ensure type safety for partition key parameters\n * - Require all parameters to be provided\n *\n * @example\n * ```ts\n * // Define a partition key template\n * const pk = partitionKey`country#${\"country\"}#enclosure#${\"enclosure\"}`;\n *\n * // Generate a partition key (all parameters required)\n * const key = pk({ country: \"NZ\", enclosure: \"A1\" });\n * // Result: \"country#NZ#enclosure#A1\"\n *\n * // Type checking ensures all parameters are provided\n * const invalidKey = pk({ country: \"NZ\" }); // TypeScript error\n * ```\n *\n * @param strings - The static parts of the template string\n * @param keys - The dynamic parts of the template string that will be replaced with values\n *\n * @returns A function that accepts an object with the dynamic values and returns the formatted partition key\n */\nexport function partitionKey<T extends readonly string[]>(\n strings: TemplateStringsArray,\n ...keys: T\n): (params: StrictGenerateType<T>) => string {\n return (params) => {\n let result = strings[0] ?? \"\";\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key) {\n result += params[key as T[number]] + (strings[i + 1] ?? \"\");\n }\n }\n\n return result;\n };\n}\n"]}
@@ -1,32 +0,0 @@
1
- type StrictGenerateType<T extends readonly string[]> = {
2
- [K in T[number]]: string;
3
- };
4
- /**
5
- * Creates a template function for generating DynamoDB partition keys with dynamic values.
6
- * Use this function when you need to:
7
- * - Create consistent partition key patterns with variable parts
8
- * - Generate partition keys that follow a specific format
9
- * - Ensure type safety for partition key parameters
10
- * - Require all parameters to be provided
11
- *
12
- * @example
13
- * ```ts
14
- * // Define a partition key template
15
- * const pk = partitionKey`country#${"country"}#enclosure#${"enclosure"}`;
16
- *
17
- * // Generate a partition key (all parameters required)
18
- * const key = pk({ country: "NZ", enclosure: "A1" });
19
- * // Result: "country#NZ#enclosure#A1"
20
- *
21
- * // Type checking ensures all parameters are provided
22
- * const invalidKey = pk({ country: "NZ" }); // TypeScript error
23
- * ```
24
- *
25
- * @param strings - The static parts of the template string
26
- * @param keys - The dynamic parts of the template string that will be replaced with values
27
- *
28
- * @returns A function that accepts an object with the dynamic values and returns the formatted partition key
29
- */
30
- declare function partitionKey<T extends readonly string[]>(strings: TemplateStringsArray, ...keys: T): (params: StrictGenerateType<T>) => string;
31
-
32
- export { type StrictGenerateType, partitionKey };
@@ -1,32 +0,0 @@
1
- type StrictGenerateType<T extends readonly string[]> = {
2
- [K in T[number]]: string;
3
- };
4
- /**
5
- * Creates a template function for generating DynamoDB partition keys with dynamic values.
6
- * Use this function when you need to:
7
- * - Create consistent partition key patterns with variable parts
8
- * - Generate partition keys that follow a specific format
9
- * - Ensure type safety for partition key parameters
10
- * - Require all parameters to be provided
11
- *
12
- * @example
13
- * ```ts
14
- * // Define a partition key template
15
- * const pk = partitionKey`country#${"country"}#enclosure#${"enclosure"}`;
16
- *
17
- * // Generate a partition key (all parameters required)
18
- * const key = pk({ country: "NZ", enclosure: "A1" });
19
- * // Result: "country#NZ#enclosure#A1"
20
- *
21
- * // Type checking ensures all parameters are provided
22
- * const invalidKey = pk({ country: "NZ" }); // TypeScript error
23
- * ```
24
- *
25
- * @param strings - The static parts of the template string
26
- * @param keys - The dynamic parts of the template string that will be replaced with values
27
- *
28
- * @returns A function that accepts an object with the dynamic values and returns the formatted partition key
29
- */
30
- declare function partitionKey<T extends readonly string[]>(strings: TemplateStringsArray, ...keys: T): (params: StrictGenerateType<T>) => string;
31
-
32
- export { type StrictGenerateType, partitionKey };
@@ -1,17 +0,0 @@
1
- // src/utils/partition-key-template.ts
2
- function partitionKey(strings, ...keys) {
3
- return (params) => {
4
- let result = strings[0] ?? "";
5
- for (let i = 0; i < keys.length; i++) {
6
- const key = keys[i];
7
- if (key) {
8
- result += params[key] + (strings[i + 1] ?? "");
9
- }
10
- }
11
- return result;
12
- };
13
- }
14
-
15
- export { partitionKey };
16
- //# sourceMappingURL=partition-key-template.js.map
17
- //# sourceMappingURL=partition-key-template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/partition-key-template.ts"],"names":[],"mappings":";AA8BO,SAAS,YAAA,CACd,YACG,IACwC,EAAA;AAC3C,EAAA,OAAO,CAAC,MAAW,KAAA;AACjB,IAAI,IAAA,MAAA,GAAS,OAAQ,CAAA,CAAC,CAAK,IAAA,EAAA;AAE3B,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CAAK,EAAA,EAAA;AACpC,MAAM,MAAA,GAAA,GAAM,KAAK,CAAC,CAAA;AAClB,MAAA,IAAI,GAAK,EAAA;AACP,QAAA,MAAA,IAAU,OAAO,GAAgB,CAAA,IAAK,OAAQ,CAAA,CAAA,GAAI,CAAC,CAAK,IAAA,EAAA,CAAA;AAAA;AAC1D;AAGF,IAAO,OAAA,MAAA;AAAA,GACT;AACF","file":"partition-key-template.js","sourcesContent":["export type StrictGenerateType<T extends readonly string[]> = {\n [K in T[number]]: string;\n};\n\n/**\n * Creates a template function for generating DynamoDB partition keys with dynamic values.\n * Use this function when you need to:\n * - Create consistent partition key patterns with variable parts\n * - Generate partition keys that follow a specific format\n * - Ensure type safety for partition key parameters\n * - Require all parameters to be provided\n *\n * @example\n * ```ts\n * // Define a partition key template\n * const pk = partitionKey`country#${\"country\"}#enclosure#${\"enclosure\"}`;\n *\n * // Generate a partition key (all parameters required)\n * const key = pk({ country: \"NZ\", enclosure: \"A1\" });\n * // Result: \"country#NZ#enclosure#A1\"\n *\n * // Type checking ensures all parameters are provided\n * const invalidKey = pk({ country: \"NZ\" }); // TypeScript error\n * ```\n *\n * @param strings - The static parts of the template string\n * @param keys - The dynamic parts of the template string that will be replaced with values\n *\n * @returns A function that accepts an object with the dynamic values and returns the formatted partition key\n */\nexport function partitionKey<T extends readonly string[]>(\n strings: TemplateStringsArray,\n ...keys: T\n): (params: StrictGenerateType<T>) => string {\n return (params) => {\n let result = strings[0] ?? \"\";\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key) {\n result += params[key as T[number]] + (strings[i + 1] ?? \"\");\n }\n }\n\n return result;\n };\n}\n"]}
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- // src/utils/sort-key-template.ts
4
- function sortKey(strings, ...keys) {
5
- return (params) => {
6
- let result = strings[0] ?? "";
7
- for (let i = 0; i < keys.length; i++) {
8
- const key = keys[i];
9
- if (key && params && key in params) {
10
- result += params[key] + (strings[i + 1] ?? "");
11
- }
12
- }
13
- return result;
14
- };
15
- }
16
-
17
- exports.sortKey = sortKey;
18
- //# sourceMappingURL=sort-key-template.cjs.map
19
- //# sourceMappingURL=sort-key-template.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/sort-key-template.ts"],"names":[],"mappings":";;;AAqCO,SAAS,OAAA,CACd,YACG,IACkC,EAAA;AACrC,EAAA,OAAO,CAAC,MAAW,KAAA;AACjB,IAAI,IAAA,MAAA,GAAS,OAAQ,CAAA,CAAC,CAAK,IAAA,EAAA;AAE3B,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CAAK,EAAA,EAAA;AACpC,MAAM,MAAA,GAAA,GAAM,KAAK,CAAC,CAAA;AAElB,MAAI,IAAA,GAAA,IAAO,MAAU,IAAA,GAAA,IAAO,MAAQ,EAAA;AAClC,QAAA,MAAA,IAAU,OAAO,GAAG,CAAA,IAAK,OAAQ,CAAA,CAAA,GAAI,CAAC,CAAK,IAAA,EAAA,CAAA;AAAA;AAC7C;AAGF,IAAO,OAAA,MAAA;AAAA,GACT;AACF","file":"sort-key-template.cjs","sourcesContent":["export type GenerateType<T extends readonly string[], U extends string = never> = T extends [infer F, ...infer R]\n ? F extends string\n ? R extends string[]\n ? ({ [K in F | U]: string | number } & Partial<Record<Exclude<T[number], F | U>, never>>) | GenerateType<R, F | U>\n : never\n : never\n : never;\n\n/**\n * Creates a template function for generating DynamoDB sort keys with dynamic values.\n * Use this function when you need to:\n * - Create consistent sort key patterns with variable parts\n * - Generate sort keys that follow a specific format\n * - Ensure type safety for sort key parameters\n *\n * @example\n * ```ts\n * // Define a sort key template\n * const sk = sortKey`country#${\"country\"}#enclosure#${\"enclosure\"}#diet#${\"diet\"}`;\n *\n * // Generate a sort key with partial parameters\n * const templatedString = sk({ country: \"NZ\", enclosure: \"A1\" });\n * // Result: \"country#NZ#enclosure#A1#diet#\"\n *\n * // Generate a complete sort key\n * const fullKey = sk({ country: \"NZ\", enclosure: \"A1\", diet: \"carnivore\" });\n * // Result: \"country#NZ#enclosure#A1#diet#carnivore\"\n *\n * // Type checking ensures only valid parameters are used\n * const invalidKey = sk({ country: \"NZ\", invalid: \"value\" }); // TypeScript error\n * ```\n *\n * @param strings - The static parts of the template string\n * @param keys - The dynamic parts of the template string that will be replaced with values\n *\n * @returns A function that accepts an object with the dynamic values and returns the formatted sort key\n */\nexport function sortKey<T extends readonly string[]>(\n strings: TemplateStringsArray,\n ...keys: T\n): (params: GenerateType<T>) => string {\n return (params) => {\n let result = strings[0] ?? \"\";\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (key && params && key in params) {\n result += params[key] + (strings[i + 1] ?? \"\");\n }\n }\n\n return result;\n };\n}\n"]}
@@ -1,35 +0,0 @@
1
- type GenerateType<T extends readonly string[], U extends string = never> = T extends [infer F, ...infer R] ? F extends string ? R extends string[] ? ({
2
- [K in F | U]: string | number;
3
- } & Partial<Record<Exclude<T[number], F | U>, never>>) | GenerateType<R, F | U> : never : never : never;
4
- /**
5
- * Creates a template function for generating DynamoDB sort keys with dynamic values.
6
- * Use this function when you need to:
7
- * - Create consistent sort key patterns with variable parts
8
- * - Generate sort keys that follow a specific format
9
- * - Ensure type safety for sort key parameters
10
- *
11
- * @example
12
- * ```ts
13
- * // Define a sort key template
14
- * const sk = sortKey`country#${"country"}#enclosure#${"enclosure"}#diet#${"diet"}`;
15
- *
16
- * // Generate a sort key with partial parameters
17
- * const templatedString = sk({ country: "NZ", enclosure: "A1" });
18
- * // Result: "country#NZ#enclosure#A1#diet#"
19
- *
20
- * // Generate a complete sort key
21
- * const fullKey = sk({ country: "NZ", enclosure: "A1", diet: "carnivore" });
22
- * // Result: "country#NZ#enclosure#A1#diet#carnivore"
23
- *
24
- * // Type checking ensures only valid parameters are used
25
- * const invalidKey = sk({ country: "NZ", invalid: "value" }); // TypeScript error
26
- * ```
27
- *
28
- * @param strings - The static parts of the template string
29
- * @param keys - The dynamic parts of the template string that will be replaced with values
30
- *
31
- * @returns A function that accepts an object with the dynamic values and returns the formatted sort key
32
- */
33
- declare function sortKey<T extends readonly string[]>(strings: TemplateStringsArray, ...keys: T): (params: GenerateType<T>) => string;
34
-
35
- export { type GenerateType, sortKey };
@@ -1,35 +0,0 @@
1
- type GenerateType<T extends readonly string[], U extends string = never> = T extends [infer F, ...infer R] ? F extends string ? R extends string[] ? ({
2
- [K in F | U]: string | number;
3
- } & Partial<Record<Exclude<T[number], F | U>, never>>) | GenerateType<R, F | U> : never : never : never;
4
- /**
5
- * Creates a template function for generating DynamoDB sort keys with dynamic values.
6
- * Use this function when you need to:
7
- * - Create consistent sort key patterns with variable parts
8
- * - Generate sort keys that follow a specific format
9
- * - Ensure type safety for sort key parameters
10
- *
11
- * @example
12
- * ```ts
13
- * // Define a sort key template
14
- * const sk = sortKey`country#${"country"}#enclosure#${"enclosure"}#diet#${"diet"}`;
15
- *
16
- * // Generate a sort key with partial parameters
17
- * const templatedString = sk({ country: "NZ", enclosure: "A1" });
18
- * // Result: "country#NZ#enclosure#A1#diet#"
19
- *
20
- * // Generate a complete sort key
21
- * const fullKey = sk({ country: "NZ", enclosure: "A1", diet: "carnivore" });
22
- * // Result: "country#NZ#enclosure#A1#diet#carnivore"
23
- *
24
- * // Type checking ensures only valid parameters are used
25
- * const invalidKey = sk({ country: "NZ", invalid: "value" }); // TypeScript error
26
- * ```
27
- *
28
- * @param strings - The static parts of the template string
29
- * @param keys - The dynamic parts of the template string that will be replaced with values
30
- *
31
- * @returns A function that accepts an object with the dynamic values and returns the formatted sort key
32
- */
33
- declare function sortKey<T extends readonly string[]>(strings: TemplateStringsArray, ...keys: T): (params: GenerateType<T>) => string;
34
-
35
- export { type GenerateType, sortKey };
@@ -1,17 +0,0 @@
1
- // src/utils/sort-key-template.ts
2
- function sortKey(strings, ...keys) {
3
- return (params) => {
4
- let result = strings[0] ?? "";
5
- for (let i = 0; i < keys.length; i++) {
6
- const key = keys[i];
7
- if (key && params && key in params) {
8
- result += params[key] + (strings[i + 1] ?? "");
9
- }
10
- }
11
- return result;
12
- };
13
- }
14
-
15
- export { sortKey };
16
- //# sourceMappingURL=sort-key-template.js.map
17
- //# sourceMappingURL=sort-key-template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/sort-key-template.ts"],"names":[],"mappings":";AAqCO,SAAS,OAAA,CACd,YACG,IACkC,EAAA;AACrC,EAAA,OAAO,CAAC,MAAW,KAAA;AACjB,IAAI,IAAA,MAAA,GAAS,OAAQ,CAAA,CAAC,CAAK,IAAA,EAAA;AAE3B,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CAAK,EAAA,EAAA;AACpC,MAAM,MAAA,GAAA,GAAM,KAAK,CAAC,CAAA;AAElB,MAAI,IAAA,GAAA,IAAO,MAAU,IAAA,GAAA,IAAO,MAAQ,EAAA;AAClC,QAAA,MAAA,IAAU,OAAO,GAAG,CAAA,IAAK,OAAQ,CAAA,CAAA,GAAI,CAAC,CAAK,IAAA,EAAA,CAAA;AAAA;AAC7C;AAGF,IAAO,OAAA,MAAA;AAAA,GACT;AACF","file":"sort-key-template.js","sourcesContent":["export type GenerateType<T extends readonly string[], U extends string = never> = T extends [infer F, ...infer R]\n ? F extends string\n ? R extends string[]\n ? ({ [K in F | U]: string | number } & Partial<Record<Exclude<T[number], F | U>, never>>) | GenerateType<R, F | U>\n : never\n : never\n : never;\n\n/**\n * Creates a template function for generating DynamoDB sort keys with dynamic values.\n * Use this function when you need to:\n * - Create consistent sort key patterns with variable parts\n * - Generate sort keys that follow a specific format\n * - Ensure type safety for sort key parameters\n *\n * @example\n * ```ts\n * // Define a sort key template\n * const sk = sortKey`country#${\"country\"}#enclosure#${\"enclosure\"}#diet#${\"diet\"}`;\n *\n * // Generate a sort key with partial parameters\n * const templatedString = sk({ country: \"NZ\", enclosure: \"A1\" });\n * // Result: \"country#NZ#enclosure#A1#diet#\"\n *\n * // Generate a complete sort key\n * const fullKey = sk({ country: \"NZ\", enclosure: \"A1\", diet: \"carnivore\" });\n * // Result: \"country#NZ#enclosure#A1#diet#carnivore\"\n *\n * // Type checking ensures only valid parameters are used\n * const invalidKey = sk({ country: \"NZ\", invalid: \"value\" }); // TypeScript error\n * ```\n *\n * @param strings - The static parts of the template string\n * @param keys - The dynamic parts of the template string that will be replaced with values\n *\n * @returns A function that accepts an object with the dynamic values and returns the formatted sort key\n */\nexport function sortKey<T extends readonly string[]>(\n strings: TemplateStringsArray,\n ...keys: T\n): (params: GenerateType<T>) => string {\n return (params) => {\n let result = strings[0] ?? \"\";\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (key && params && key in params) {\n result += params[key] + (strings[i + 1] ?? \"\");\n }\n }\n\n return result;\n };\n}\n"]}