@proofkit/fmodata 0.1.0-alpha.8 → 0.1.0-alpha.9

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.
@@ -61,12 +61,12 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
61
61
  * // On insert/update: only notes is available (id and system fields excluded)
62
62
  * ```
63
63
  */
64
- export declare class BaseTable<Schema extends Record<string, StandardSchemaV1> = any, IdField extends keyof Schema | undefined = undefined, Required extends readonly (keyof Schema)[] = readonly [], ReadOnly extends readonly (keyof Schema)[] = readonly []> {
64
+ export declare class BaseTable<Schema extends Record<string, StandardSchemaV1> = any, IdField extends keyof Schema | undefined = undefined, Required extends readonly (keyof Schema | (string & {}))[] = readonly [], ReadOnly extends readonly (keyof Schema | (string & {}))[] = readonly []> {
65
65
  readonly schema: Schema;
66
66
  readonly idField?: IdField;
67
67
  readonly required?: Required;
68
68
  readonly readOnly?: ReadOnly;
69
- readonly fmfIds?: Record<keyof Schema, `FMFID:${string}`>;
69
+ readonly fmfIds?: Record<keyof Schema | (string & {}), `FMFID:${string}`>;
70
70
  constructor(config: {
71
71
  schema: Schema;
72
72
  idField?: IdField;
@@ -114,12 +114,12 @@ export declare class BaseTable<Schema extends Record<string, StandardSchemaV1> =
114
114
  * });
115
115
  * ```
116
116
  */
117
- export declare function defineBaseTable<const Schema extends Record<string, StandardSchemaV1>, IdField extends keyof Schema | undefined = undefined, const Required extends readonly (keyof Schema)[] = readonly [], const ReadOnly extends readonly (keyof Schema)[] = readonly []>(config: {
117
+ export declare function defineBaseTable<const Schema extends Record<string, StandardSchemaV1>, IdField extends keyof Schema | undefined = undefined, const Required extends readonly (keyof Schema | (string & {}))[] = readonly [], const ReadOnly extends readonly (keyof Schema | (string & {}))[] = readonly []>(config: {
118
118
  schema: Schema;
119
119
  idField?: IdField;
120
120
  required?: Required;
121
121
  readOnly?: ReadOnly;
122
122
  fmfIds?: {
123
- [K in keyof Schema]: `FMFID:${string}`;
123
+ [K in keyof Schema | (string & {})]: `FMFID:${string}`;
124
124
  };
125
125
  }): BaseTable<Schema, IdField, Required, ReadOnly>;
@@ -1 +1 @@
1
- {"version":3,"file":"base-table.js","sources":["../../../src/client/base-table.ts"],"sourcesContent":["import { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * BaseTable defines the schema and configuration for a table.\n *\n * @template Schema - Record of field names to StandardSchemaV1 validators\n * @template IdField - The name of the primary key field (optional, automatically read-only)\n * @template Required - Additional field names to require on insert (beyond auto-inferred required fields)\n * @template ReadOnly - Field names that cannot be modified via insert/update (idField is automatically read-only)\n *\n * @example Basic table with auto-inferred required fields\n * ```ts\n * import { z } from \"zod\";\n *\n * const usersTable = new BaseTable({\n * schema: {\n * id: z.string(), // Auto-required (not nullable), auto-readOnly (idField)\n * name: z.string(), // Auto-required (not nullable)\n * email: z.string().nullable(), // Optional (nullable)\n * },\n * idField: \"id\",\n * });\n * // On insert: name is required, email is optional (id is excluded - readOnly)\n * // On update: name and email available (id is excluded - readOnly)\n * ```\n *\n * @example Table with additional required and readOnly fields\n * ```ts\n * import { z } from \"zod\";\n *\n * const usersTable = new BaseTable({\n * schema: {\n * id: z.string(), // Auto-required, auto-readOnly (idField)\n * createdAt: z.string(), // Read-only system field\n * name: z.string(), // Auto-required\n * email: z.string().nullable(), // Optional by default...\n * legacyField: z.string().nullable(), // Optional by default...\n * },\n * idField: \"id\",\n * required: [\"legacyField\"], // Make legacyField required for new inserts\n * readOnly: [\"createdAt\"], // Exclude from insert/update\n * });\n * // On insert: name and legacyField required; email optional (id and createdAt excluded)\n * // On update: all fields optional (id and createdAt excluded)\n * ```\n *\n * @example Table with multiple read-only fields\n * ```ts\n * import { z } from \"zod\";\n *\n * const usersTable = new BaseTable({\n * schema: {\n * id: z.string(),\n * createdAt: z.string(),\n * modifiedAt: z.string(),\n * createdBy: z.string(),\n * notes: z.string().nullable(),\n * },\n * idField: \"id\",\n * readOnly: [\"createdAt\", \"modifiedAt\", \"createdBy\"],\n * });\n * // On insert/update: only notes is available (id and system fields excluded)\n * ```\n */\nexport class BaseTable<\n Schema extends Record<string, StandardSchemaV1> = any,\n IdField extends keyof Schema | undefined = undefined,\n Required extends readonly (keyof Schema)[] = readonly [],\n ReadOnly extends readonly (keyof Schema)[] = readonly [],\n> {\n public readonly schema: Schema;\n public readonly idField?: IdField;\n public readonly required?: Required;\n public readonly readOnly?: ReadOnly;\n public readonly fmfIds?: Record<keyof Schema, `FMFID:${string}`>;\n\n constructor(config: {\n schema: Schema;\n idField?: IdField;\n required?: Required;\n readOnly?: ReadOnly;\n fmfIds?: Record<string, `FMFID:${string}`>;\n }) {\n this.schema = config.schema;\n this.idField = config.idField;\n this.required = config.required;\n this.readOnly = config.readOnly;\n this.fmfIds = config.fmfIds as\n | Record<keyof Schema, `FMFID:${string}`>\n | undefined;\n }\n\n /**\n * Returns the FileMaker field ID (FMFID) for a given field name, or the field name itself if not using IDs.\n * @param fieldName - The field name to get the ID for\n * @returns The FMFID string or the original field name\n */\n getFieldId(fieldName: keyof Schema): string {\n if (this.fmfIds && fieldName in this.fmfIds) {\n return this.fmfIds[fieldName];\n }\n return String(fieldName);\n }\n\n /**\n * Returns the field name for a given FileMaker field ID (FMFID), or the ID itself if not found.\n * @param fieldId - The FMFID to get the field name for\n * @returns The field name or the original ID\n */\n getFieldName(fieldId: string): string {\n if (this.fmfIds) {\n // Search for the field name that corresponds to this FMFID\n for (const [fieldName, fmfId] of Object.entries(this.fmfIds)) {\n if (fmfId === fieldId) {\n return fieldName;\n }\n }\n }\n return fieldId;\n }\n\n /**\n * Returns true if this BaseTable is using FileMaker field IDs.\n */\n isUsingFieldIds(): boolean {\n return this.fmfIds !== undefined;\n }\n}\n\n/**\n * Creates a BaseTable with proper TypeScript type inference.\n *\n * This function should be used instead of `new BaseTable()` to ensure\n * field names are properly typed throughout the library.\n *\n * @example Without entity IDs\n * ```ts\n * const users = defineBaseTable({\n * schema: { id: z.string(), name: z.string() },\n * idField: \"id\",\n * });\n * ```\n *\n * @example With entity IDs (FileMaker field IDs)\n * ```ts\n * const products = defineBaseTable({\n * schema: { id: z.string(), name: z.string() },\n * idField: \"id\",\n * fmfIds: { id: \"FMFID:1\", name: \"FMFID:2\" },\n * });\n * ```\n */\nexport function defineBaseTable<\n const Schema extends Record<string, StandardSchemaV1>,\n IdField extends keyof Schema | undefined = undefined,\n const Required extends readonly (keyof Schema)[] = readonly [],\n const ReadOnly extends readonly (keyof Schema)[] = readonly [],\n>(config: {\n schema: Schema;\n idField?: IdField;\n required?: Required;\n readOnly?: ReadOnly;\n fmfIds?: { [K in keyof Schema]: `FMFID:${string}` };\n}): BaseTable<Schema, IdField, Required, ReadOnly> {\n return new BaseTable(config);\n}\n"],"names":[],"mappings":";;;AAgEO,MAAM,UAKX;AAAA,EAOA,YAAY,QAMT;AAZa;AACA;AACA;AACA;AACA;AASd,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO;AACtB,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,OAAO;AACvB,SAAK,SAAS,OAAO;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUvB,WAAW,WAAiC;AAC1C,QAAI,KAAK,UAAU,aAAa,KAAK,QAAQ;AACpC,aAAA,KAAK,OAAO,SAAS;AAAA,IAAA;AAE9B,WAAO,OAAO,SAAS;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzB,aAAa,SAAyB;AACpC,QAAI,KAAK,QAAQ;AAEJ,iBAAA,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,KAAK,MAAM,GAAG;AAC5D,YAAI,UAAU,SAAS;AACd,iBAAA;AAAA,QAAA;AAAA,MACT;AAAA,IACF;AAEK,WAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMT,kBAA2B;AACzB,WAAO,KAAK,WAAW;AAAA,EAAA;AAE3B;AAyBO,SAAS,gBAKd,QAMiD;AAC1C,SAAA,IAAI,UAAU,MAAM;AAC7B;"}
1
+ {"version":3,"file":"base-table.js","sources":["../../../src/client/base-table.ts"],"sourcesContent":["import { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * BaseTable defines the schema and configuration for a table.\n *\n * @template Schema - Record of field names to StandardSchemaV1 validators\n * @template IdField - The name of the primary key field (optional, automatically read-only)\n * @template Required - Additional field names to require on insert (beyond auto-inferred required fields)\n * @template ReadOnly - Field names that cannot be modified via insert/update (idField is automatically read-only)\n *\n * @example Basic table with auto-inferred required fields\n * ```ts\n * import { z } from \"zod\";\n *\n * const usersTable = new BaseTable({\n * schema: {\n * id: z.string(), // Auto-required (not nullable), auto-readOnly (idField)\n * name: z.string(), // Auto-required (not nullable)\n * email: z.string().nullable(), // Optional (nullable)\n * },\n * idField: \"id\",\n * });\n * // On insert: name is required, email is optional (id is excluded - readOnly)\n * // On update: name and email available (id is excluded - readOnly)\n * ```\n *\n * @example Table with additional required and readOnly fields\n * ```ts\n * import { z } from \"zod\";\n *\n * const usersTable = new BaseTable({\n * schema: {\n * id: z.string(), // Auto-required, auto-readOnly (idField)\n * createdAt: z.string(), // Read-only system field\n * name: z.string(), // Auto-required\n * email: z.string().nullable(), // Optional by default...\n * legacyField: z.string().nullable(), // Optional by default...\n * },\n * idField: \"id\",\n * required: [\"legacyField\"], // Make legacyField required for new inserts\n * readOnly: [\"createdAt\"], // Exclude from insert/update\n * });\n * // On insert: name and legacyField required; email optional (id and createdAt excluded)\n * // On update: all fields optional (id and createdAt excluded)\n * ```\n *\n * @example Table with multiple read-only fields\n * ```ts\n * import { z } from \"zod\";\n *\n * const usersTable = new BaseTable({\n * schema: {\n * id: z.string(),\n * createdAt: z.string(),\n * modifiedAt: z.string(),\n * createdBy: z.string(),\n * notes: z.string().nullable(),\n * },\n * idField: \"id\",\n * readOnly: [\"createdAt\", \"modifiedAt\", \"createdBy\"],\n * });\n * // On insert/update: only notes is available (id and system fields excluded)\n * ```\n */\nexport class BaseTable<\n Schema extends Record<string, StandardSchemaV1> = any,\n IdField extends keyof Schema | undefined = undefined,\n Required extends readonly (keyof Schema | (string & {}))[] = readonly [],\n ReadOnly extends readonly (keyof Schema | (string & {}))[] = readonly [],\n> {\n public readonly schema: Schema;\n public readonly idField?: IdField;\n public readonly required?: Required;\n public readonly readOnly?: ReadOnly;\n public readonly fmfIds?: Record<\n keyof Schema | (string & {}),\n `FMFID:${string}`\n >;\n\n constructor(config: {\n schema: Schema;\n idField?: IdField;\n required?: Required;\n readOnly?: ReadOnly;\n fmfIds?: Record<string, `FMFID:${string}`>;\n }) {\n this.schema = config.schema;\n this.idField = config.idField;\n this.required = config.required;\n this.readOnly = config.readOnly;\n this.fmfIds = config.fmfIds as\n | Record<keyof Schema, `FMFID:${string}`>\n | undefined;\n }\n\n /**\n * Returns the FileMaker field ID (FMFID) for a given field name, or the field name itself if not using IDs.\n * @param fieldName - The field name to get the ID for\n * @returns The FMFID string or the original field name\n */\n getFieldId(fieldName: keyof Schema): string {\n if (this.fmfIds && fieldName in this.fmfIds) {\n return this.fmfIds[fieldName];\n }\n return String(fieldName);\n }\n\n /**\n * Returns the field name for a given FileMaker field ID (FMFID), or the ID itself if not found.\n * @param fieldId - The FMFID to get the field name for\n * @returns The field name or the original ID\n */\n getFieldName(fieldId: string): string {\n if (this.fmfIds) {\n // Search for the field name that corresponds to this FMFID\n for (const [fieldName, fmfId] of Object.entries(this.fmfIds)) {\n if (fmfId === fieldId) {\n return fieldName;\n }\n }\n }\n return fieldId;\n }\n\n /**\n * Returns true if this BaseTable is using FileMaker field IDs.\n */\n isUsingFieldIds(): boolean {\n return this.fmfIds !== undefined;\n }\n}\n\n/**\n * Creates a BaseTable with proper TypeScript type inference.\n *\n * This function should be used instead of `new BaseTable()` to ensure\n * field names are properly typed throughout the library.\n *\n * @example Without entity IDs\n * ```ts\n * const users = defineBaseTable({\n * schema: { id: z.string(), name: z.string() },\n * idField: \"id\",\n * });\n * ```\n *\n * @example With entity IDs (FileMaker field IDs)\n * ```ts\n * const products = defineBaseTable({\n * schema: { id: z.string(), name: z.string() },\n * idField: \"id\",\n * fmfIds: { id: \"FMFID:1\", name: \"FMFID:2\" },\n * });\n * ```\n */\nexport function defineBaseTable<\n const Schema extends Record<string, StandardSchemaV1>,\n IdField extends keyof Schema | undefined = undefined,\n const Required extends readonly (\n | keyof Schema\n | (string & {})\n )[] = readonly [],\n const ReadOnly extends readonly (\n | keyof Schema\n | (string & {})\n )[] = readonly [],\n>(config: {\n schema: Schema;\n idField?: IdField;\n required?: Required;\n readOnly?: ReadOnly;\n fmfIds?: { [K in keyof Schema | (string & {})]: `FMFID:${string}` };\n}): BaseTable<Schema, IdField, Required, ReadOnly> {\n return new BaseTable(config);\n}\n"],"names":[],"mappings":";;;AAgEO,MAAM,UAKX;AAAA,EAUA,YAAY,QAMT;AAfa;AACA;AACA;AACA;AACA;AAYd,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO;AACtB,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,OAAO;AACvB,SAAK,SAAS,OAAO;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUvB,WAAW,WAAiC;AAC1C,QAAI,KAAK,UAAU,aAAa,KAAK,QAAQ;AACpC,aAAA,KAAK,OAAO,SAAS;AAAA,IAAA;AAE9B,WAAO,OAAO,SAAS;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzB,aAAa,SAAyB;AACpC,QAAI,KAAK,QAAQ;AAEJ,iBAAA,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,KAAK,MAAM,GAAG;AAC5D,YAAI,UAAU,SAAS;AACd,iBAAA;AAAA,QAAA;AAAA,MACT;AAAA,IACF;AAEK,WAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMT,kBAA2B;AACzB,WAAO,KAAK,WAAW;AAAA,EAAA;AAE3B;AAyBO,SAAS,gBAWd,QAMiD;AAC1C,SAAA,IAAI,UAAU,MAAM;AAC7B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofkit/fmodata",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "FileMaker OData API client",
5
5
  "repository": "git@github.com:proofgeist/proofkit.git",
6
6
  "author": "Eric <37158449+eluce2@users.noreply.github.com>",
@@ -65,14 +65,17 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
65
65
  export class BaseTable<
66
66
  Schema extends Record<string, StandardSchemaV1> = any,
67
67
  IdField extends keyof Schema | undefined = undefined,
68
- Required extends readonly (keyof Schema)[] = readonly [],
69
- ReadOnly extends readonly (keyof Schema)[] = readonly [],
68
+ Required extends readonly (keyof Schema | (string & {}))[] = readonly [],
69
+ ReadOnly extends readonly (keyof Schema | (string & {}))[] = readonly [],
70
70
  > {
71
71
  public readonly schema: Schema;
72
72
  public readonly idField?: IdField;
73
73
  public readonly required?: Required;
74
74
  public readonly readOnly?: ReadOnly;
75
- public readonly fmfIds?: Record<keyof Schema, `FMFID:${string}`>;
75
+ public readonly fmfIds?: Record<
76
+ keyof Schema | (string & {}),
77
+ `FMFID:${string}`
78
+ >;
76
79
 
77
80
  constructor(config: {
78
81
  schema: Schema;
@@ -153,14 +156,20 @@ export class BaseTable<
153
156
  export function defineBaseTable<
154
157
  const Schema extends Record<string, StandardSchemaV1>,
155
158
  IdField extends keyof Schema | undefined = undefined,
156
- const Required extends readonly (keyof Schema)[] = readonly [],
157
- const ReadOnly extends readonly (keyof Schema)[] = readonly [],
159
+ const Required extends readonly (
160
+ | keyof Schema
161
+ | (string & {})
162
+ )[] = readonly [],
163
+ const ReadOnly extends readonly (
164
+ | keyof Schema
165
+ | (string & {})
166
+ )[] = readonly [],
158
167
  >(config: {
159
168
  schema: Schema;
160
169
  idField?: IdField;
161
170
  required?: Required;
162
171
  readOnly?: ReadOnly;
163
- fmfIds?: { [K in keyof Schema]: `FMFID:${string}` };
172
+ fmfIds?: { [K in keyof Schema | (string & {})]: `FMFID:${string}` };
164
173
  }): BaseTable<Schema, IdField, Required, ReadOnly> {
165
174
  return new BaseTable(config);
166
175
  }