@deepraxis/sdk 0.2.0-dev.c2bf6fc → 0.2.0-dev.c7e8740

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.
@@ -22,4 +22,17 @@ export type RenameParameters<D, A extends AliasMap> = {
22
22
  [K in keyof D]: K extends keyof A ? RenameFields<D[K], A[K]> : D[K];
23
23
  };
24
24
  export declare function aliasOperation(operation: Operation, aliases: AliasMap): Operation;
25
+ /**
26
+ * Path keys an older caller still spells (#5154): `ns` for `namespace`, `id` for `run_id`. The map is canonical name to
27
+ * legacy name. The wire only ever sees the canonical key; both spellings at once is a caller bug and is refused.
28
+ */
29
+ type LegacyPathMap = Record<string, string>;
30
+ export type AcceptLegacyPath<D, M extends LegacyPathMap> = D extends {
31
+ path: infer P;
32
+ } ? Omit<D, 'path'> & {
33
+ path: P | (Omit<P, keyof M & keyof P> & {
34
+ [K in keyof M & keyof P as M[K]]: P[K];
35
+ });
36
+ } : D;
37
+ export declare function acceptLegacyPath(operation: Operation, legacy: LegacyPathMap): Operation;
25
38
  export {};
@@ -43,3 +43,20 @@ export function aliasOperation(operation, aliases) {
43
43
  return operation(mapped);
44
44
  };
45
45
  }
46
+ export function acceptLegacyPath(operation, legacy) {
47
+ return options => {
48
+ const path = options?.path;
49
+ if (path === undefined || path === null || typeof path !== 'object')
50
+ return operation(options);
51
+ const mapped = { ...path };
52
+ for (const [canonical, old] of Object.entries(legacy)) {
53
+ if (!Object.hasOwn(mapped, old))
54
+ continue;
55
+ if (Object.hasOwn(mapped, canonical))
56
+ throw new TypeError(`Use only path.${canonical}; path.${old} is its deprecated alias`);
57
+ mapped[canonical] = mapped[old];
58
+ delete mapped[old];
59
+ }
60
+ return operation({ ...options, path: mapped });
61
+ };
62
+ }
@@ -22,6 +22,7 @@ export class Praxis {
22
22
  const host = globalThis.process;
23
23
  Object.assign(resource, { connect: (options) => connectBrowser({
24
24
  contexts: resource.contexts,
25
+ sessions: resource.sessions,
25
26
  env: host?.env ?? {},
26
27
  builtin: host?.getBuiltinModule?.bind(host),
27
28
  }, options) });