@atscript/db-client 0.1.59 → 0.1.60

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.cjs CHANGED
@@ -350,13 +350,34 @@ var Client = class {
350
350
  }
351
351
  };
352
352
  /**
353
- * Encode a row identifier for substitution into a `processor: 'navigate'` URL template.
354
- * The values are URL-encoded and joined with `/` in `meta.preferredId` field
355
- * declaration order NOT in object-key insertion order (which is unstable
356
- * across callers).
353
+ * Render a single identifier field for substitution into a navigate-URL
354
+ * template or human-readable string. `null` / `undefined` collapse to `""`
355
+ * (NOT the literal `"undefined"` / `"null"` that `String()` would produce).
356
+ */
357
+ function formatIdentifierField(v) {
358
+ if (v === null || v === void 0) return "";
359
+ if (typeof v === "string") return v;
360
+ if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint") return String(v);
361
+ return JSON.stringify(v);
362
+ }
363
+ /**
364
+ * Render a row identifier as a `/`-joined string in `preferredId`
365
+ * declaration order — NOT object-key insertion order (which is unstable
366
+ * across callers). Raw form, no URL-encoding; for prompt text, error
367
+ * messages, log lines, etc.
368
+ */
369
+ function formatIdentifier(id, preferredId) {
370
+ if (id === void 0) return "";
371
+ return preferredId.map((f) => formatIdentifierField(id[f])).join("/");
372
+ }
373
+ /**
374
+ * URL-encoded form of `formatIdentifier` — for `processor: 'navigate'`
375
+ * `$1` substitution. Each field is `encodeURIComponent`'d, then joined
376
+ * with a literal `/`. Missing fields render as empty segments (e.g.
377
+ * `acme//jane`), not the literal `"undefined"`.
357
378
  */
358
379
  function encodeNavigateId(id, preferredId) {
359
- return preferredId.map((f) => encodeURIComponent(String(id[f]))).join("/");
380
+ return preferredId.map((f) => encodeURIComponent(formatIdentifierField(id[f]))).join("/");
360
381
  }
361
382
  function describeShape(value) {
362
383
  if (value === null) return "null";
@@ -369,3 +390,6 @@ exports.ActionNotFoundError = ActionNotFoundError;
369
390
  exports.ActionUnsupportedError = ActionUnsupportedError;
370
391
  exports.Client = Client;
371
392
  exports.ClientError = ClientError;
393
+ exports.encodeNavigateId = encodeNavigateId;
394
+ exports.formatIdentifier = formatIdentifier;
395
+ exports.formatIdentifierField = formatIdentifierField;
package/dist/index.d.cts CHANGED
@@ -153,6 +153,26 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape> {
153
153
  private _buildInit;
154
154
  private _send;
155
155
  }
156
+ /**
157
+ * Render a single identifier field for substitution into a navigate-URL
158
+ * template or human-readable string. `null` / `undefined` collapse to `""`
159
+ * (NOT the literal `"undefined"` / `"null"` that `String()` would produce).
160
+ */
161
+ declare function formatIdentifierField(v: unknown): string;
162
+ /**
163
+ * Render a row identifier as a `/`-joined string in `preferredId`
164
+ * declaration order — NOT object-key insertion order (which is unstable
165
+ * across callers). Raw form, no URL-encoding; for prompt text, error
166
+ * messages, log lines, etc.
167
+ */
168
+ declare function formatIdentifier(id: Record<string, unknown> | undefined, preferredId: readonly string[]): string;
169
+ /**
170
+ * URL-encoded form of `formatIdentifier` — for `processor: 'navigate'`
171
+ * `$1` substitution. Each field is `encodeURIComponent`'d, then joined
172
+ * with a literal `/`. Missing fields render as empty segments (e.g.
173
+ * `acme//jane`), not the literal `"undefined"`.
174
+ */
175
+ declare function encodeNavigateId(id: Record<string, unknown>, preferredId: readonly string[]): string;
156
176
  //#endregion
157
177
  //#region src/client-error.d.ts
158
178
  /**
@@ -225,4 +245,4 @@ declare class ActionUnsupportedError extends Error {
225
245
  constructor(action: string, processor: string, message: string);
226
246
  }
227
247
  //#endregion
228
- export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode };
248
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, encodeNavigateId, formatIdentifier, formatIdentifierField };
package/dist/index.d.mts CHANGED
@@ -153,6 +153,26 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape> {
153
153
  private _buildInit;
154
154
  private _send;
155
155
  }
156
+ /**
157
+ * Render a single identifier field for substitution into a navigate-URL
158
+ * template or human-readable string. `null` / `undefined` collapse to `""`
159
+ * (NOT the literal `"undefined"` / `"null"` that `String()` would produce).
160
+ */
161
+ declare function formatIdentifierField(v: unknown): string;
162
+ /**
163
+ * Render a row identifier as a `/`-joined string in `preferredId`
164
+ * declaration order — NOT object-key insertion order (which is unstable
165
+ * across callers). Raw form, no URL-encoding; for prompt text, error
166
+ * messages, log lines, etc.
167
+ */
168
+ declare function formatIdentifier(id: Record<string, unknown> | undefined, preferredId: readonly string[]): string;
169
+ /**
170
+ * URL-encoded form of `formatIdentifier` — for `processor: 'navigate'`
171
+ * `$1` substitution. Each field is `encodeURIComponent`'d, then joined
172
+ * with a literal `/`. Missing fields render as empty segments (e.g.
173
+ * `acme//jane`), not the literal `"undefined"`.
174
+ */
175
+ declare function encodeNavigateId(id: Record<string, unknown>, preferredId: readonly string[]): string;
156
176
  //#endregion
157
177
  //#region src/client-error.d.ts
158
178
  /**
@@ -225,4 +245,4 @@ declare class ActionUnsupportedError extends Error {
225
245
  constructor(action: string, processor: string, message: string);
226
246
  }
227
247
  //#endregion
228
- export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode };
248
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, encodeNavigateId, formatIdentifier, formatIdentifierField };
package/dist/index.mjs CHANGED
@@ -349,13 +349,34 @@ var Client = class {
349
349
  }
350
350
  };
351
351
  /**
352
- * Encode a row identifier for substitution into a `processor: 'navigate'` URL template.
353
- * The values are URL-encoded and joined with `/` in `meta.preferredId` field
354
- * declaration order NOT in object-key insertion order (which is unstable
355
- * across callers).
352
+ * Render a single identifier field for substitution into a navigate-URL
353
+ * template or human-readable string. `null` / `undefined` collapse to `""`
354
+ * (NOT the literal `"undefined"` / `"null"` that `String()` would produce).
355
+ */
356
+ function formatIdentifierField(v) {
357
+ if (v === null || v === void 0) return "";
358
+ if (typeof v === "string") return v;
359
+ if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint") return String(v);
360
+ return JSON.stringify(v);
361
+ }
362
+ /**
363
+ * Render a row identifier as a `/`-joined string in `preferredId`
364
+ * declaration order — NOT object-key insertion order (which is unstable
365
+ * across callers). Raw form, no URL-encoding; for prompt text, error
366
+ * messages, log lines, etc.
367
+ */
368
+ function formatIdentifier(id, preferredId) {
369
+ if (id === void 0) return "";
370
+ return preferredId.map((f) => formatIdentifierField(id[f])).join("/");
371
+ }
372
+ /**
373
+ * URL-encoded form of `formatIdentifier` — for `processor: 'navigate'`
374
+ * `$1` substitution. Each field is `encodeURIComponent`'d, then joined
375
+ * with a literal `/`. Missing fields render as empty segments (e.g.
376
+ * `acme//jane`), not the literal `"undefined"`.
356
377
  */
357
378
  function encodeNavigateId(id, preferredId) {
358
- return preferredId.map((f) => encodeURIComponent(String(id[f]))).join("/");
379
+ return preferredId.map((f) => encodeURIComponent(formatIdentifierField(id[f]))).join("/");
359
380
  }
360
381
  function describeShape(value) {
361
382
  if (value === null) return "null";
@@ -363,4 +384,4 @@ function describeShape(value) {
363
384
  return typeof value;
364
385
  }
365
386
  //#endregion
366
- export { ActionDisabledError, ActionNotFoundError, ActionUnsupportedError, Client, ClientError };
387
+ export { ActionDisabledError, ActionNotFoundError, ActionUnsupportedError, Client, ClientError, encodeNavigateId, formatIdentifier, formatIdentifierField };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-client",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
5
5
  "keywords": [
6
6
  "atscript",
@@ -50,7 +50,7 @@
50
50
  "@atscript/typescript": "^0.1.50",
51
51
  "@uniqu/core": "^0.1.5",
52
52
  "unplugin-atscript": "^0.1.50",
53
- "@atscript/db": "0.1.59"
53
+ "@atscript/db": "0.1.60"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@atscript/db": "^0.1.44",