@prisma-next/ids 0.5.0-dev.6 → 0.5.0-dev.61
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.
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { ulid as ulid$1 } from "uniku/ulid";
|
|
|
5
5
|
import { uuidv4 as uuidv4$1 } from "uniku/uuid/v4";
|
|
6
6
|
import { uuidv7 as uuidv7$1 } from "uniku/uuid/v7";
|
|
7
7
|
import { ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
|
|
8
|
-
import { ColumnTypeDescriptor } from "@prisma-next/
|
|
8
|
+
import { ColumnTypeDescriptor } from "@prisma-next/framework-components/codec";
|
|
9
9
|
|
|
10
10
|
//#region src/generator-ids.d.ts
|
|
11
11
|
declare const builtinGeneratorIds: readonly ["ulid", "nanoid", "uuidv7", "uuidv4", "cuid2", "ksuid"];
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["builtinGeneratorRegistryMetadata: ReadonlyArray<{\n readonly id: BuiltinGeneratorId;\n readonly applicableCodecIds: readonly string[];\n}>","metadata: BuiltinGeneratorMetadata"],"sources":["../src/generator-ids.ts","../src/index.ts"],"sourcesContent":["export const builtinGeneratorIds = [\n 'ulid',\n 'nanoid',\n 'uuidv7',\n 'uuidv4',\n 'cuid2',\n 'ksuid',\n] as const;\n\nexport type BuiltinGeneratorId = (typeof builtinGeneratorIds)[number];\n","import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';\nimport type { ColumnTypeDescriptor } from '@prisma-next/
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["builtinGeneratorRegistryMetadata: ReadonlyArray<{\n readonly id: BuiltinGeneratorId;\n readonly applicableCodecIds: readonly string[];\n}>","metadata: BuiltinGeneratorMetadata"],"sources":["../src/generator-ids.ts","../src/index.ts"],"sourcesContent":["export const builtinGeneratorIds = [\n 'ulid',\n 'nanoid',\n 'uuidv7',\n 'uuidv4',\n 'cuid2',\n 'ksuid',\n] as const;\n\nexport type BuiltinGeneratorId = (typeof builtinGeneratorIds)[number];\n","import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';\nimport type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type BuiltinGeneratorId, builtinGeneratorIds } from './generator-ids';\nimport type { IdGeneratorOptionsById } from './generators';\n\nexport { builtinGeneratorIds };\n\nexport type GeneratedColumnDescriptor = {\n readonly type: ColumnTypeDescriptor;\n readonly typeParams?: Record<string, unknown>;\n};\n\ntype BuiltinGeneratorMetadata = {\n readonly applicableCodecIds: readonly string[];\n readonly generatedColumnDescriptor: GeneratedColumnDescriptor;\n readonly resolveGeneratedColumnDescriptor?: (\n params?: Record<string, unknown>,\n ) => GeneratedColumnDescriptor;\n};\n\nfunction resolveNanoidColumnDescriptor(\n params?: Record<string, unknown>,\n): GeneratedColumnDescriptor {\n const rawSize = params?.['size'];\n if (rawSize === undefined) {\n return {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 21 },\n };\n }\n\n if (typeof rawSize !== 'number' || !Number.isInteger(rawSize) || rawSize < 2 || rawSize > 255) {\n throw new Error('nanoid size must be an integer between 2 and 255');\n }\n\n return {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: rawSize },\n };\n}\n\nconst builtinGeneratorMetadataById = {\n ulid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 26 },\n },\n },\n nanoid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 21 },\n },\n resolveGeneratedColumnDescriptor: resolveNanoidColumnDescriptor,\n },\n uuidv7: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 36 },\n },\n },\n uuidv4: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 36 },\n },\n },\n cuid2: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 24 },\n },\n },\n ksuid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 27 },\n },\n },\n} as const satisfies Record<BuiltinGeneratorId, BuiltinGeneratorMetadata>;\n\nexport const builtinGeneratorRegistryMetadata: ReadonlyArray<{\n readonly id: BuiltinGeneratorId;\n readonly applicableCodecIds: readonly string[];\n}> = builtinGeneratorIds.map((id) => ({\n id,\n applicableCodecIds: builtinGeneratorMetadataById[id].applicableCodecIds,\n}));\n\nexport function resolveBuiltinGeneratedColumnDescriptor(input: {\n readonly id: BuiltinGeneratorId;\n readonly params?: Record<string, unknown>;\n}): GeneratedColumnDescriptor {\n const metadata: BuiltinGeneratorMetadata = builtinGeneratorMetadataById[input.id];\n if (metadata.resolveGeneratedColumnDescriptor) {\n return metadata.resolveGeneratedColumnDescriptor(input.params);\n }\n return metadata.generatedColumnDescriptor;\n}\n\nexport type GeneratedColumnSpec<TCodecId extends string = string> = {\n readonly type: ColumnTypeDescriptor<TCodecId>;\n readonly nullable?: false;\n readonly typeParams?: Record<string, unknown>;\n readonly generated: ExecutionMutationDefaultValue;\n};\n\ntype GeneratorCodecId<TId extends BuiltinGeneratorId> =\n (typeof builtinGeneratorMetadataById)[TId]['generatedColumnDescriptor']['type']['codecId'];\n\nfunction createGeneratedSpec<TId extends BuiltinGeneratorId>(\n id: TId,\n options?: IdGeneratorOptionsById[TId],\n): GeneratedColumnSpec<GeneratorCodecId<TId>> {\n const params = options as Record<string, unknown> | undefined;\n const resolvedDescriptor = resolveBuiltinGeneratedColumnDescriptor({\n id,\n ...ifDefined('params', params),\n });\n return {\n type: resolvedDescriptor.type,\n nullable: false,\n ...ifDefined('typeParams', resolvedDescriptor.typeParams),\n generated: {\n kind: 'generator',\n id,\n ...ifDefined('params', params),\n },\n } as GeneratedColumnSpec<GeneratorCodecId<TId>>;\n}\n\nexport const ulid = (options?: IdGeneratorOptionsById['ulid']) =>\n createGeneratedSpec('ulid', options);\nexport const nanoid = (options?: IdGeneratorOptionsById['nanoid']) =>\n createGeneratedSpec('nanoid', options);\nexport const uuidv7 = (options?: IdGeneratorOptionsById['uuidv7']) =>\n createGeneratedSpec('uuidv7', options);\nexport const uuidv4 = (options?: IdGeneratorOptionsById['uuidv4']) =>\n createGeneratedSpec('uuidv4', options);\nexport const cuid2 = (options?: IdGeneratorOptionsById['cuid2']) =>\n createGeneratedSpec('cuid2', options);\nexport const ksuid = (options?: IdGeneratorOptionsById['ksuid']) =>\n createGeneratedSpec('ksuid', options);\n"],"mappings":";;;AAAA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACD;;;;ACcD,SAAS,8BACP,QAC2B;CAC3B,MAAM,UAAU,SAAS;AACzB,KAAI,YAAY,OACd,QAAO;EACL,MAAM;GAAE,SAAS;GAAc,YAAY;GAAa;EACxD,YAAY,EAAE,QAAQ,IAAI;EAC3B;AAGH,KAAI,OAAO,YAAY,YAAY,CAAC,OAAO,UAAU,QAAQ,IAAI,UAAU,KAAK,UAAU,IACxF,OAAM,IAAI,MAAM,mDAAmD;AAGrE,QAAO;EACL,MAAM;GAAE,SAAS;GAAc,YAAY;GAAa;EACxD,YAAY,EAAE,QAAQ,SAAS;EAChC;;AAGH,MAAM,+BAA+B;CACnC,MAAM;EACJ,oBAAo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AAM,mBAAmB;EACzB,UAAU;EACV,GAAG,UAAU,cAAc,mBAAmB,WAAW;EACzD,WAAW;GACT,MAAM;GACN;GACA,GAAG,UAAU,UAAU,OAAO;GAC/B;EACF;;AAGH,MAAa,QAAQ,YACnB,oBAAoB,QAAQ,QAAQ;AACtC,MAAa,UAAU,YACrB,oBAAoB,UAAU,QAAQ;AACxC,MAAa,UAAU,YACrB,oBAAoB,UAAU,QAAQ;AACxC,MAAa,UAAU,YACrB,oBAAoB,UAAU,QAAQ;AACxC,MAAa,SAAS,YACpB,oBAAoB,SAAS,QAAQ;AACvC,MAAa,SAAS,YACpB,oBAAoB,SAAS,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/ids",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.61",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"description": "ID generator helpers for Prisma Next contracts",
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"uniku": "^0.0.12",
|
|
9
|
-
"@prisma-next/contract": "0.5.0-dev.
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/
|
|
10
|
+
"@prisma-next/contract": "0.5.0-dev.61",
|
|
11
|
+
"@prisma-next/utils": "0.5.0-dev.61",
|
|
12
|
+
"@prisma-next/framework-components": "0.5.0-dev.61"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
15
|
"tsdown": "0.18.4",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
|
|
2
|
-
import type { ColumnTypeDescriptor } from '@prisma-next/
|
|
2
|
+
import type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';
|
|
3
3
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
4
4
|
import { type BuiltinGeneratorId, builtinGeneratorIds } from './generator-ids';
|
|
5
5
|
import type { IdGeneratorOptionsById } from './generators';
|