@vrplatform/api 1.3.1-stage.4789 → 1.3.1-stage.4793

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.
@@ -14,4 +14,9 @@ export declare function resolveTenantRouting({ connectionId, slug, tenantId, aut
14
14
  slug?: string;
15
15
  tenantId?: string;
16
16
  }): Promise<TenantRouting>;
17
+ /**
18
+ * Resolve a tenant's home region and return an API client configured for that
19
+ * regional API. The resolved tenant id is applied to every regional request.
20
+ */
21
+ export declare function useResolvedApiClient({ connectionId, slug, tenantId, auth, ...apiClientOptions }: Parameters<typeof resolveTenantRouting>[0]): Promise<import("./types").ApiClient>;
17
22
  export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveTenantRouting = resolveTenantRouting;
4
+ exports.useResolvedApiClient = useResolvedApiClient;
4
5
  const client_1 = require("./client");
5
6
  const error_1 = require("./error");
6
7
  /**
@@ -37,4 +38,25 @@ async function resolveTenantRouting({ connectionId, slug, tenantId, auth, ...api
37
38
  apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\/$/, ''),
38
39
  };
39
40
  }
41
+ /**
42
+ * Resolve a tenant's home region and return an API client configured for that
43
+ * regional API. The resolved tenant id is applied to every regional request.
44
+ */
45
+ async function useResolvedApiClient({ connectionId, slug, tenantId, auth, ...apiClientOptions }) {
46
+ const routing = await resolveTenantRouting({
47
+ ...apiClientOptions,
48
+ connectionId,
49
+ slug,
50
+ tenantId,
51
+ auth,
52
+ });
53
+ return (0, client_1.useApiClient)({
54
+ ...apiClientOptions,
55
+ baseUrl: routing.apiBaseUrl,
56
+ auth: () => ({
57
+ ...(typeof auth === 'function' ? auth() : (auth ?? {})),
58
+ tenantId: routing.id,
59
+ }),
60
+ });
61
+ }
40
62
  //# sourceMappingURL=routing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"src/","sources":["routing.ts"],"names":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';\nimport type { ApiClientAuth, ResponseData } from './types';\n\nexport type TenantRouting = Pick<\n ResponseData<'get:/teams/resolve'>,\n 'id' | 'slug' | 'dataRegion' | 'apiBaseUrl'\n>;\n\ntype ApiClientOptions = Parameters<typeof useApiClient>[0];\n\n/**\n * Resolve a tenant's region and regional `apiBaseUrl` from a connection id,\n * slug, or tenant id — the client entry point for non-API runtimes that need\n * to reach a tenant's home region. Each call is a `/teams/resolve` round trip;\n * hot-loop callers should cache the result (placement changes only on an\n * explicit tenant migration).\n */\nexport async function resolveTenantRouting({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: ApiClientOptions & {\n connectionId?: string;\n slug?: string;\n tenantId?: string;\n}): Promise<TenantRouting> {\n if (!connectionId && !slug && !tenantId) {\n throw new Error('connectionId, slug, or tenantId is required');\n }\n\n const response = throwIfError(\n await useApiClient({\n ...apiClientOptions,\n auth: tenantId\n ? () => {\n const current = typeof auth === 'function' ? auth() : (auth ?? {});\n return {\n ...current,\n tenantId,\n } satisfies ApiClientAuth;\n }\n : auth,\n }).GET('/teams/resolve', {\n params: {\n query: slug ? { slug } : connectionId ? { connectionId } : {},\n },\n })\n );\n\n return {\n id: response.id,\n slug: response.slug,\n dataRegion: response.dataRegion,\n apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\\/$/, ''),\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"src/","sources":["routing.ts"],"names":[],"mappings":";;AAkBA,oDAwCC;AAMD,oDAwBC;AAxFD,qCAAwC;AACxC,mCAAuC;AAUvC;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,EACzC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,GAAG,gBAAgB,EAKpB;IACC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,M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AAE,CACT,CAAC;YACC,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACvD,QAAQ,EAAE,OAAO,CAAC,EAAE;SACrB,CAAyB;KAC7B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useApiClient } from './client';\nimport { throwIfError } from './error';\nimport type { ApiClientAuth, ResponseData } from './types';\n\nexport type TenantRouting = Pick<\n ResponseData<'get:/teams/resolve'>,\n 'id' | 'slug' | 'dataRegion' | 'apiBaseUrl'\n>;\n\ntype ApiClientOptions = Parameters<typeof useApiClient>[0];\n\n/**\n * Resolve a tenant's region and regional `apiBaseUrl` from a connection id,\n * slug, or tenant id — the client entry point for non-API runtimes that need\n * to reach a tenant's home region. Each call is a `/teams/resolve` round trip;\n * hot-loop callers should cache the result (placement changes only on an\n * explicit tenant migration).\n */\nexport async function resolveTenantRouting({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: ApiClientOptions & {\n connectionId?: string;\n slug?: string;\n tenantId?: string;\n}): Promise<TenantRouting> {\n if (!connectionId && !slug && !tenantId) {\n throw new Error('connectionId, slug, or tenantId is required');\n }\n\n const response = throwIfError(\n await useApiClient({\n ...apiClientOptions,\n auth: tenantId\n ? () => {\n const current = typeof auth === 'function' ? auth() : (auth ?? {});\n return {\n ...current,\n tenantId,\n } satisfies ApiClientAuth;\n }\n : auth,\n }).GET('/teams/resolve', {\n params: {\n query: slug ? { slug } : connectionId ? { connectionId } : {},\n },\n })\n );\n\n return {\n id: response.id,\n slug: response.slug,\n dataRegion: response.dataRegion,\n apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\\/$/, ''),\n };\n}\n\n/**\n * Resolve a tenant's home region and return an API client configured for that\n * regional API. The resolved tenant id is applied to every regional request.\n */\nexport async function useResolvedApiClient({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: Parameters<typeof resolveTenantRouting>[0]) {\n const routing = await resolveTenantRouting({\n ...apiClientOptions,\n connectionId,\n slug,\n tenantId,\n auth,\n });\n\n return useApiClient({\n ...apiClientOptions,\n baseUrl: routing.apiBaseUrl,\n auth: () =>\n ({\n ...(typeof auth === 'function' ? auth() : (auth ?? {})),\n tenantId: routing.id,\n }) satisfies ApiClientAuth,\n });\n}\n"]}
@@ -14,4 +14,9 @@ export declare function resolveTenantRouting({ connectionId, slug, tenantId, aut
14
14
  slug?: string;
15
15
  tenantId?: string;
16
16
  }): Promise<TenantRouting>;
17
+ /**
18
+ * Resolve a tenant's home region and return an API client configured for that
19
+ * regional API. The resolved tenant id is applied to every regional request.
20
+ */
21
+ export declare function useResolvedApiClient({ connectionId, slug, tenantId, auth, ...apiClientOptions }: Parameters<typeof resolveTenantRouting>[0]): Promise<import("./types").ApiClient>;
17
22
  export {};
@@ -34,4 +34,25 @@ export async function resolveTenantRouting({ connectionId, slug, tenantId, auth,
34
34
  apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\/$/, ''),
35
35
  };
36
36
  }
37
+ /**
38
+ * Resolve a tenant's home region and return an API client configured for that
39
+ * regional API. The resolved tenant id is applied to every regional request.
40
+ */
41
+ export async function useResolvedApiClient({ connectionId, slug, tenantId, auth, ...apiClientOptions }) {
42
+ const routing = await resolveTenantRouting({
43
+ ...apiClientOptions,
44
+ connectionId,
45
+ slug,
46
+ tenantId,
47
+ auth,
48
+ });
49
+ return useApiClient({
50
+ ...apiClientOptions,
51
+ baseUrl: routing.apiBaseUrl,
52
+ auth: () => ({
53
+ ...(typeof auth === 'function' ? auth() : (auth ?? {})),
54
+ tenantId: routing.id,
55
+ }),
56
+ });
57
+ }
37
58
  //# sourceMappingURL=routing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"src/","sources":["routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,GAAG,gBAAgB,EAKpB;IACC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,QAAQ,GAAG,YAAY,CAC3B,MAAM,YAAY,CAAC;QACjB,GAAG,gBAAgB;QACnB,IAAI,EAAE,QAAQ;YACZ,CAAC,CAAC,GAAG,EAAE;gBACH,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;gBACnE,OAAO;oBACL,GAAG,OAAO;oBACV,QAAQ;iBACe,CAAC;YAC5B,CAAC;YACH,CAAC,CAAC,IAAI;KACT,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE;QACvB,MAAM,EAAE;YACN,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE;SAC9D;KACF,CAAC,CACH,CAAC;IAEF,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,UAAU,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;KACvE,CAAC;AACJ,CAAC","sourcesContent":["import { useApiClient } from './client';\nimport { throwIfError } from './error';\nimport type { ApiClientAuth, ResponseData } from './types';\n\nexport type TenantRouting = Pick<\n ResponseData<'get:/teams/resolve'>,\n 'id' | 'slug' | 'dataRegion' | 'apiBaseUrl'\n>;\n\ntype ApiClientOptions = Parameters<typeof useApiClient>[0];\n\n/**\n * Resolve a tenant's region and regional `apiBaseUrl` from a connection id,\n * slug, or tenant id — the client entry point for non-API runtimes that need\n * to reach a tenant's home region. Each call is a `/teams/resolve` round trip;\n * hot-loop callers should cache the result (placement changes only on an\n * explicit tenant migration).\n */\nexport async function resolveTenantRouting({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: ApiClientOptions & {\n connectionId?: string;\n slug?: string;\n tenantId?: string;\n}): Promise<TenantRouting> {\n if (!connectionId && !slug && !tenantId) {\n throw new Error('connectionId, slug, or tenantId is required');\n }\n\n const response = throwIfError(\n await useApiClient({\n ...apiClientOptions,\n auth: tenantId\n ? () => {\n const current = typeof auth === 'function' ? auth() : (auth ?? {});\n return {\n ...current,\n tenantId,\n } satisfies ApiClientAuth;\n }\n : auth,\n }).GET('/teams/resolve', {\n params: {\n query: slug ? { slug } : connectionId ? { connectionId } : {},\n },\n })\n );\n\n return {\n id: response.id,\n slug: response.slug,\n dataRegion: response.dataRegion,\n apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\\/$/, ''),\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"src/","sources":["routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,GAAG,gBAAgB,EAKpB;IACC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC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AAG,EAAE,CACT,CAAC;YACC,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACvD,QAAQ,EAAE,OAAO,CAAC,EAAE;SACrB,CAAyB;KAC7B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useApiClient } from './client';\nimport { throwIfError } from './error';\nimport type { ApiClientAuth, ResponseData } from './types';\n\nexport type TenantRouting = Pick<\n ResponseData<'get:/teams/resolve'>,\n 'id' | 'slug' | 'dataRegion' | 'apiBaseUrl'\n>;\n\ntype ApiClientOptions = Parameters<typeof useApiClient>[0];\n\n/**\n * Resolve a tenant's region and regional `apiBaseUrl` from a connection id,\n * slug, or tenant id — the client entry point for non-API runtimes that need\n * to reach a tenant's home region. Each call is a `/teams/resolve` round trip;\n * hot-loop callers should cache the result (placement changes only on an\n * explicit tenant migration).\n */\nexport async function resolveTenantRouting({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: ApiClientOptions & {\n connectionId?: string;\n slug?: string;\n tenantId?: string;\n}): Promise<TenantRouting> {\n if (!connectionId && !slug && !tenantId) {\n throw new Error('connectionId, slug, or tenantId is required');\n }\n\n const response = throwIfError(\n await useApiClient({\n ...apiClientOptions,\n auth: tenantId\n ? () => {\n const current = typeof auth === 'function' ? auth() : (auth ?? {});\n return {\n ...current,\n tenantId,\n } satisfies ApiClientAuth;\n }\n : auth,\n }).GET('/teams/resolve', {\n params: {\n query: slug ? { slug } : connectionId ? { connectionId } : {},\n },\n })\n );\n\n return {\n id: response.id,\n slug: response.slug,\n dataRegion: response.dataRegion,\n apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\\/$/, ''),\n };\n}\n\n/**\n * Resolve a tenant's home region and return an API client configured for that\n * regional API. The resolved tenant id is applied to every regional request.\n */\nexport async function useResolvedApiClient({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: Parameters<typeof resolveTenantRouting>[0]) {\n const routing = await resolveTenantRouting({\n ...apiClientOptions,\n connectionId,\n slug,\n tenantId,\n auth,\n });\n\n return useApiClient({\n ...apiClientOptions,\n baseUrl: routing.apiBaseUrl,\n auth: () =>\n ({\n ...(typeof auth === 'function' ? auth() : (auth ?? {})),\n tenantId: routing.id,\n }) satisfies ApiClientAuth,\n });\n}\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.1-stage.4789",
6
+ "version": "1.3.1-stage.4793",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",
package/src/routing.ts CHANGED
@@ -57,3 +57,33 @@ export async function resolveTenantRouting({
57
57
  apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\/$/, ''),
58
58
  };
59
59
  }
60
+
61
+ /**
62
+ * Resolve a tenant's home region and return an API client configured for that
63
+ * regional API. The resolved tenant id is applied to every regional request.
64
+ */
65
+ export async function useResolvedApiClient({
66
+ connectionId,
67
+ slug,
68
+ tenantId,
69
+ auth,
70
+ ...apiClientOptions
71
+ }: Parameters<typeof resolveTenantRouting>[0]) {
72
+ const routing = await resolveTenantRouting({
73
+ ...apiClientOptions,
74
+ connectionId,
75
+ slug,
76
+ tenantId,
77
+ auth,
78
+ });
79
+
80
+ return useApiClient({
81
+ ...apiClientOptions,
82
+ baseUrl: routing.apiBaseUrl,
83
+ auth: () =>
84
+ ({
85
+ ...(typeof auth === 'function' ? auth() : (auth ?? {})),
86
+ tenantId: routing.id,
87
+ }) satisfies ApiClientAuth,
88
+ });
89
+ }