zitejs 0.10.0-start.22 → 0.10.0-start.24

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.
Files changed (42) hide show
  1. package/dist/cjs/cli.js +1 -1
  2. package/dist/cjs/start/provider.d.ts +2 -2
  3. package/dist/cjs/start/provider.js +7 -7
  4. package/dist/cjs/start/types.d.ts +32 -50
  5. package/dist/cjs/sync/lib.js +23 -50
  6. package/dist/cjs/sync/sdkNames.d.ts +65 -7
  7. package/dist/cjs/sync/sdkNames.js +76 -12
  8. package/dist/cjs/sync/sdkNames.test.js +38 -0
  9. package/dist/esm/cli.js +1 -1
  10. package/dist/esm/start/airtable/built.d.ts +2 -0
  11. package/dist/esm/start/airtable/built.js +3 -0
  12. package/dist/esm/start/airtable/index.d.ts +3 -5
  13. package/dist/esm/start/airtable/index.js +4 -25
  14. package/dist/esm/start/airtable/settings.d.ts +31 -0
  15. package/dist/esm/start/airtable/settings.js +110 -0
  16. package/dist/esm/start/data/index.d.ts +21 -9
  17. package/dist/esm/start/data/index.js +26 -20
  18. package/dist/esm/start/data/names.d.ts +7 -0
  19. package/dist/esm/start/data/names.js +15 -0
  20. package/dist/esm/start/data/types.d.ts +4 -1
  21. package/dist/esm/start/direct.d.ts +16 -12
  22. package/dist/esm/start/direct.js +185 -56
  23. package/dist/esm/start/outbound.d.ts +4 -5
  24. package/dist/esm/start/outbound.js +38 -49
  25. package/dist/esm/start/provider.d.ts +2 -2
  26. package/dist/esm/start/provider.js +7 -7
  27. package/dist/esm/start/server.d.ts +17 -13
  28. package/dist/esm/start/server.js +43 -45
  29. package/dist/esm/start/telemetry.d.ts +4 -1
  30. package/dist/esm/start/telemetry.js +13 -16
  31. package/dist/esm/start/types.d.ts +32 -50
  32. package/dist/esm/start/version.d.ts +1 -1
  33. package/dist/esm/start/version.js +1 -1
  34. package/dist/esm/start/vite.d.ts +7 -1
  35. package/dist/esm/start/vite.js +68 -21
  36. package/dist/esm/start/workspaceSchema.d.ts +2 -1
  37. package/dist/esm/start/workspaceSchema.js +3 -3
  38. package/dist/esm/sync/lib.js +23 -50
  39. package/dist/esm/sync/sdkNames.d.ts +65 -7
  40. package/dist/esm/sync/sdkNames.js +73 -11
  41. package/dist/esm/sync/sdkNames.test.js +38 -0
  42. package/package.json +2 -2
package/dist/esm/cli.js CHANGED
@@ -52,7 +52,7 @@ async function main() {
52
52
  console.error("A Start app under `vite dev` reaches Zite's data and services with these, from the app's .env:");
53
53
  console.error(" ZITE_DEV_API_KEY Your Zite API key, as the MCP takes it: mints dev tokens for the app zite.config.json's id names; each lasts 15 minutes and is renewed before it expires");
54
54
  console.error(' ZITE_DEV_TOKEN A dev token to use as it is instead, never renewed');
55
- console.error(' ZITE_URLS JSON naming the platform: {"baseRunner","backend","aiGateway"?,"runs"?,"email"?,"pdf"?,"uploads"?,"steps"?}; a service it doesn\'t name is the backend\'s');
55
+ console.error(' ZITE_URLS JSON naming the platform: {"baseRunner","backend","gateway"?,"runs"?,"email"?,"pdf"?,"uploads"?,"steps"?}; a service it doesn\'t name is the backend\'s');
56
56
  console.error(' ZITE_DEV_USER JSON of the signed-in stand-in: {"id","email","name"?,"roles"?,"isInternal"?}; unset, nobody is');
57
57
  process.exit(1);
58
58
  }
@@ -0,0 +1,2 @@
1
+ import type { BuiltAirtableSettings } from "./settings.js";
2
+ export declare const builtAirtableSettings: Record<string, BuiltAirtableSettings> | null;
@@ -0,0 +1,3 @@
1
+ // Null as published. `zite()` replaces this module, in a server build and under `vite dev`, with the app's Airtable
2
+ // integrations, read from its own and its workspace's zite.config.json and zite.lock.
3
+ export const builtAirtableSettings = null;
@@ -1,8 +1,6 @@
1
1
  import { type AirtableSettings } from "./dispatch.js";
2
- import type { PlatformSession, HostRequestState } from "../types.js";
2
+ import type { HostRequestState, PlatformCallResult } from "../types.js";
3
3
  /** The build's Airtable integration `integrationId`, or undefined when it isn't one. */
4
- export declare const airtableSettingsOf: (session: Pick<PlatformSession, "integrationSettings">, integrationId: string) => Promise<AirtableSettings | undefined>;
4
+ export declare const airtableSettingsOf: (integrationId: string) => AirtableSettings | undefined;
5
5
  /** One generated Airtable table call, run here with the connection's token, which the outbound fetch refreshes on a 401. */
6
- export declare function runAirtableCall(host: HostRequestState, session: PlatformSession, integrationId: string, settings: AirtableSettings, methodName: string, params: unknown, access: "signedIn" | "anyone" | "webhook" | "workflow"): Promise<unknown>;
7
- /** For tests: forget what this isolate learned. */
8
- export declare const resetAirtableSettings: () => void;
6
+ export declare function runAirtableCall(host: HostRequestState, connectionOf: () => Promise<PlatformCallResult>, integrationId: string, settings: AirtableSettings, methodName: string, params: unknown): Promise<unknown>;
@@ -1,33 +1,16 @@
1
+ import { builtAirtableSettings } from "./built.js";
1
2
  import { executeAirtableCall } from "./dispatch.js";
2
- import { INTEGRATIONS_PLATFORM_ID } from "../credentials.js";
3
3
  import { ZiteError, isZiteErrorCode } from "../errors.js";
4
4
  import { rememberConnection } from "../outbound.js";
5
5
  const AIRTABLE_API = "https://api.airtable.com";
6
- // A build's integrations don't change, so per isolate: only answers, never a pending call.
7
- const settingsHeld = new Map();
8
6
  /** The build's Airtable integration `integrationId`, or undefined when it isn't one. */
9
- export const airtableSettingsOf = async (session, integrationId) => {
10
- if (settingsHeld.has(integrationId))
11
- return settingsHeld.get(integrationId) ?? undefined;
12
- const answer = await session.integrationSettings(integrationId);
13
- const settings = answer?.serviceType === "airtable" && typeof answer.baseId === "string"
14
- ? { baseId: answer.baseId, nameMappings: answer.nameMappings ?? null }
15
- : null;
16
- settingsHeld.set(integrationId, settings);
17
- return settings ?? undefined;
18
- };
7
+ export const airtableSettingsOf = (integrationId) => builtAirtableSettings && Object.hasOwn(builtAirtableSettings, integrationId) ? builtAirtableSettings[integrationId] : undefined;
19
8
  /** One generated Airtable table call, run here with the connection's token, which the outbound fetch refreshes on a 401. */
20
- export async function runAirtableCall(host, session, integrationId, settings, methodName, params, access) {
9
+ export async function runAirtableCall(host, connectionOf, integrationId, settings, methodName, params) {
21
10
  // As classic: a demo reaches no connected account.
22
11
  if (host.mode === "demo")
23
12
  throw new ZiteError("FORBIDDEN", "This action is not available in demo mode");
24
- const connection = await session.call({
25
- integrationId: INTEGRATIONS_PLATFORM_ID,
26
- className: "Connections",
27
- methodName: "get",
28
- params: { name: integrationId },
29
- access,
30
- });
13
+ const connection = await connectionOf();
31
14
  if ("error" in connection) {
32
15
  const { code, message, userFacingMessage } = connection.error;
33
16
  throw new ZiteError({ code: isZiteErrorCode(code) ? code : "INTERNAL_ERROR", message, userFacingMessage });
@@ -48,7 +31,3 @@ export async function runAirtableCall(host, session, integrationId, settings, me
48
31
  }),
49
32
  }, methodName, params);
50
33
  }
51
- /** For tests: forget what this isolate learned. */
52
- export const resetAirtableSettings = () => {
53
- settingsHeld.clear();
54
- };
@@ -0,0 +1,31 @@
1
+ import type { AirtableNameMappings } from "./dispatch.js";
2
+ type ConfigEntry = {
3
+ type?: unknown;
4
+ base?: unknown;
5
+ } & Record<string, unknown>;
6
+ type ConfigFile = {
7
+ integrations?: Record<string, ConfigEntry>;
8
+ integrationSettings?: Record<string, unknown>;
9
+ };
10
+ type LockFile = {
11
+ integrations?: Record<string, {
12
+ idMappings?: unknown;
13
+ } | undefined>;
14
+ };
15
+ /** An Airtable integration as the build declares it, in the platform's shape. */
16
+ export type BuiltAirtableSettings = {
17
+ serviceType: "airtable";
18
+ baseId: string;
19
+ nameMappings: AirtableNameMappings | null;
20
+ };
21
+ export type AirtableSources = {
22
+ appConfig?: ConfigFile;
23
+ appLock?: LockFile;
24
+ workspaceConfig?: ConfigFile;
25
+ workspaceLock?: LockFile;
26
+ /** With zite.schema.json the workspace database is the schema's, and an app's own `databases` entry is dropped. */
27
+ hasSchema: boolean;
28
+ };
29
+ /** Each Airtable integration the build can call, by name, as the platform's `startIntegrationSettings` answers. */
30
+ export declare const airtableSettingsFrom: ({ appConfig, appLock, workspaceConfig, workspaceLock, hasSchema }: AirtableSources) => Record<string, BuiltAirtableSettings>;
31
+ export {};
@@ -0,0 +1,110 @@
1
+ // A build's Airtable integrations, from the repo files the platform derives them from (restly's
2
+ // `getEffectiveAppIntegrations`, through `startIntegrationSettings`): the app's own entries, then the workspace's it
3
+ // has settings for, each read against the app's zite.lock. Keep the two in step.
4
+ import { isCredentialServiceType, NON_CREDENTIAL_SERVICE_TYPES, normalizeIntegrationServiceType } from "../../integrations/rules.js";
5
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6
+ const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
7
+ // Airtable base ids look like `appXYZ…`; anything else is a display name, which only the lock resolves.
8
+ const isAirtableBaseId = (value) => /^app[A-Za-z0-9]{14}$/.test(String(value));
9
+ /** An Airtable entry with its base and the lock's mappings; throws on a legacy lock with no base, as the platform does. */
10
+ const convert = (name, base, lock) => {
11
+ const lockData = lock?.integrations?.[name]?.idMappings;
12
+ let baseId = base ?? "";
13
+ const lockIsForBase = (lockBase) => !isAirtableBaseId(baseId) || lockBase === baseId;
14
+ const tables = {};
15
+ const enriched = isRecord(lockData) && Array.isArray(lockData.tables);
16
+ if (enriched && lockIsForBase(lockData.base)) {
17
+ baseId = lockData.base;
18
+ for (const table of lockData.tables) {
19
+ tables[table.id] = {
20
+ mapping: { sdkName: table.sdkName },
21
+ primaryFieldId: table.primaryFieldId,
22
+ fields: Object.fromEntries(table.fields.map((field) => [
23
+ field.id,
24
+ {
25
+ mapping: { sdkName: field.sdkName },
26
+ fieldType: field.type,
27
+ fieldName: field.name,
28
+ ...(field.config ? { fieldOptions: field.config } : {}),
29
+ },
30
+ ])),
31
+ };
32
+ }
33
+ }
34
+ else if (lockData && !enriched) {
35
+ const legacy = lockData;
36
+ if (!legacy.base)
37
+ throw new Error(`Airtable lock missing base ID for integration "${name}"`);
38
+ if (lockIsForBase(legacy.base)) {
39
+ baseId = legacy.base;
40
+ for (const [sdkName, tableId] of Object.entries(legacy.tables ?? {})) {
41
+ tables[tableId] = {
42
+ mapping: { sdkName },
43
+ fields: Object.fromEntries(Object.entries(legacy.fields?.[sdkName] ?? {}).map(([fieldSdkName, fieldId]) => [fieldId, { mapping: { sdkName: fieldSdkName } }])),
44
+ };
45
+ }
46
+ }
47
+ }
48
+ return { baseId, nameMappings: { bases: { [String(baseId)]: { mapping: { sdkName: base }, tables } } } };
49
+ };
50
+ const isAirtable = (entry) => entry?.type === "airtable";
51
+ const isServiceType = (type) => {
52
+ const normalized = typeof type === "string" ? normalizeIntegrationServiceType(type) : undefined;
53
+ return normalized !== undefined && (isCredentialServiceType(normalized) || NON_CREDENTIAL_SERVICE_TYPES.includes(normalized));
54
+ };
55
+ const isOptionalString = (value) => value === undefined || value === null || typeof value === "string";
56
+ /**
57
+ * Whether the platform's conversion of an entry gets past what any type checks (`convertConfigToIntegrationTemplate`
58
+ * throws on an unknown or missing type, a connectionId that isn't a string, and an email sender that isn't one).
59
+ * The platform skips an entry it can't read, whatever its type.
60
+ */
61
+ const platformReads = (entry) => isRecord(entry) &&
62
+ isServiceType(entry.type) &&
63
+ (!entry.connectionId || typeof entry.connectionId === "string") &&
64
+ (normalizeIntegrationServiceType(String(entry.type)) !== "email" || (isOptionalString(entry.fromName) && isOptionalString(entry.fromEmail)));
65
+ /** Each Airtable integration the build can call, by name, as the platform's `startIntegrationSettings` answers. */
66
+ export const airtableSettingsFrom = ({ appConfig, appLock, workspaceConfig, workspaceLock, hasSchema }) => {
67
+ // The app's own entries, each shadowing the workspace's of its name: only those the platform could read.
68
+ const own = {};
69
+ const effective = [];
70
+ for (const [name, entry] of Object.entries(appConfig?.integrations ?? {})) {
71
+ if ((hasSchema && entry?.type === "databases") || !platformReads(entry))
72
+ continue;
73
+ if (isAirtable(entry)) {
74
+ try {
75
+ effective.push([name, convert(name, entry.base, appLock)]);
76
+ }
77
+ catch {
78
+ continue;
79
+ }
80
+ }
81
+ own[name] = entry;
82
+ }
83
+ const settings = isRecord(appConfig?.integrationSettings) ? appConfig.integrationSettings : undefined;
84
+ for (const [name, entry] of Object.entries(workspaceConfig?.integrations ?? {})) {
85
+ // A workspace Airtable is the app's only once the app names it in its settings.
86
+ if (!isAirtable(entry) || !platformReads(entry) || hasOwn(own, name) || !settings || !hasOwn(settings, name))
87
+ continue;
88
+ let workspace;
89
+ try {
90
+ workspace = convert(name, entry.base, workspaceLock);
91
+ }
92
+ catch {
93
+ continue;
94
+ }
95
+ let applied = workspace;
96
+ const appSettings = settings[name];
97
+ if (appSettings) {
98
+ const base = isRecord(appSettings) && hasOwn(appSettings, "base") ? appSettings.base : workspace.baseId;
99
+ try {
100
+ applied = convert(name, base, appLock);
101
+ }
102
+ catch {
103
+ applied = workspace;
104
+ }
105
+ }
106
+ if (applied.baseId)
107
+ effective.push([name, applied]);
108
+ }
109
+ return Object.fromEntries(effective.flatMap(([name, { baseId, nameMappings }]) => typeof baseId === "string" ? [[name, { serviceType: "airtable", baseId, nameMappings }]] : []));
110
+ };
@@ -1,15 +1,27 @@
1
- import type { DataNameMappings } from "./types.js";
2
- import type { HostMode, PlatformSession } from "../types.js";
1
+ import type { BaseTable, DataNameMappings } from "./types.js";
2
+ import { type SchemaNames } from "../../sync/sdkNames.js";
3
+ import type { HostMode } from "../types.js";
3
4
  /** What generated `zite.*` calls go out under. */
4
5
  export declare const DATA_INTEGRATION_ID = "databases";
5
- type Found = {
6
+ /** Sends one base-runner request on the app's token. */
7
+ export type DataTransport = {
8
+ dataFetch(request: {
9
+ method: string;
10
+ path: string;
11
+ body?: string;
12
+ }): Promise<Response>;
13
+ };
14
+ /** The build's base, and the SDK names it was built with. */
15
+ export type DataTarget = {
6
16
  baseId: string | null;
7
- nameMappings: DataNameMappings | null;
17
+ names: SchemaNames | null;
8
18
  };
9
- /** The build's base and SDK names, asked of the platform once per isolate. */
10
- export declare const dataContextOf: (session: Pick<PlatformSession, "dataContext">) => Promise<Found>;
11
- /** One `zite.*` call, translated here and sent to base-runner: on the app token, or through the host's session. */
12
- export declare function runDataCall(session: Pick<PlatformSession, "dataFetch">, found: Found, mode: HostMode, methodName: string, sent: unknown): Promise<unknown>;
19
+ /**
20
+ * The build's names for the base's tables as they are now: the ones it was built with, locked, and for anything added
21
+ * since, the name `zitejs generate` would give it. Worked out once per read of the tables.
22
+ */
23
+ export declare const nameMappingsFor: (live: readonly BaseTable[], names: SchemaNames | null) => DataNameMappings;
24
+ /** One `zite.*` call, translated here and sent to base-runner on the app token. */
25
+ export declare function runDataCall(session: DataTransport, target: DataTarget, mode: HostMode, methodName: string, sent: unknown): Promise<unknown>;
13
26
  /** For tests: forget what this isolate learned. */
14
27
  export declare const resetDataDispatch: () => void;
15
- export {};
@@ -1,12 +1,13 @@
1
1
  import { createBaseRunner } from "./baseRunner.js";
2
2
  import { asZiteClientError, executeDatabasesCall } from "./dispatch.js";
3
+ import { nameMappingsOf } from "./names.js";
4
+ import { allocateLiveNames } from "../../sync/sdkNames.js";
3
5
  /** What generated `zite.*` calls go out under. */
4
6
  export const DATA_INTEGRATION_ID = "databases";
5
7
  // Schema changes aren't redeployed, so a new table or field reaches calls within this, as on the host.
6
8
  const TABLES_REUSE_MS = 60_000;
7
- // One build per script, so per isolate: what the platform says the build's base is, and that base's tables.
8
- // Only answers are kept, never a pending call: one request's RPC session mustn't hold up another's.
9
- let context;
9
+ // One build per script, so per isolate: its base's tables. Only answers are kept, never a pending call: one request's
10
+ // I/O mustn't hold up another's.
10
11
  let tables;
11
12
  const tablesOf = async (baseRunner, baseId) => {
12
13
  if (tables?.baseId === baseId && Date.now() - tables.at < TABLES_REUSE_MS)
@@ -15,44 +16,49 @@ const tablesOf = async (baseRunner, baseId) => {
15
16
  tables = { baseId, tables: base.tables, at: Date.now() };
16
17
  return base.tables;
17
18
  };
18
- /** The build's base and SDK names, asked of the platform once per isolate. */
19
- export const dataContextOf = async (session) => {
20
- if (context)
21
- return context;
22
- const answer = await session.dataContext();
23
- context = { baseId: answer.baseId, nameMappings: answer.nameMappings ?? null };
24
- return context;
19
+ const completed = new WeakMap();
20
+ /**
21
+ * The build's names for the base's tables as they are now: the ones it was built with, locked, and for anything added
22
+ * since, the name `zitejs generate` would give it. Worked out once per read of the tables.
23
+ */
24
+ export const nameMappingsFor = (live, names) => {
25
+ const held = completed.get(live);
26
+ if (held?.names === names)
27
+ return held.mappings;
28
+ const mappings = nameMappingsOf(allocateLiveNames(live, names ?? undefined).names);
29
+ completed.set(live, { names, mappings });
30
+ return mappings;
25
31
  };
26
32
  /**
27
33
  * The table id classic's generated client sends: its SDK name mapped through the
28
34
  * build's name mappings, which on classic the client does from the run's config.
29
35
  */
30
36
  const tableIdOf = (nameMappings, sent) => {
31
- for (const [id, table] of Object.entries(nameMappings?.tables ?? {})) {
37
+ for (const [id, table] of Object.entries(nameMappings.tables)) {
32
38
  if (table.mapping?.sdkName === sent)
33
39
  return id;
34
40
  }
35
41
  return sent;
36
42
  };
37
- /** One `zite.*` call, translated here and sent to base-runner: on the app token, or through the host's session. */
38
- export async function runDataCall(session, found, mode, methodName, sent) {
39
- const params = sent && typeof sent === "object" && typeof sent.tableId === "string"
40
- ? { ...sent, tableId: tableIdOf(found.nameMappings, sent.tableId) }
41
- : sent;
42
- if (!found.baseId)
43
+ /** One `zite.*` call, translated here and sent to base-runner on the app token. */
44
+ export async function runDataCall(session, target, mode, methodName, sent) {
45
+ if (!target.baseId)
43
46
  throw asZiteClientError(Object.assign(new Error("This app has no database"), { statusCode: 404 }));
44
47
  const baseRunner = createBaseRunner((request) => session.dataFetch(request));
45
48
  let baseTables;
46
49
  try {
47
- baseTables = await tablesOf(baseRunner, found.baseId);
50
+ baseTables = await tablesOf(baseRunner, target.baseId);
48
51
  }
49
52
  catch (error) {
50
53
  throw asZiteClientError(error);
51
54
  }
52
- return executeDatabasesCall({ baseRunner, baseId: found.baseId, nameMappings: found.nameMappings, tables: baseTables, readOnly: mode === "demo" }, methodName, params);
55
+ const nameMappings = nameMappingsFor(baseTables, target.names);
56
+ const params = sent && typeof sent === "object" && typeof sent.tableId === "string"
57
+ ? { ...sent, tableId: tableIdOf(nameMappings, sent.tableId) }
58
+ : sent;
59
+ return executeDatabasesCall({ baseRunner, baseId: target.baseId, nameMappings, tables: baseTables, readOnly: mode === "demo" }, methodName, params);
53
60
  }
54
61
  /** For tests: forget what this isolate learned. */
55
62
  export const resetDataDispatch = () => {
56
- context = undefined;
57
63
  tables = undefined;
58
64
  };
@@ -0,0 +1,7 @@
1
+ import { type SchemaNames } from "../../sync/sdkNames.js";
2
+ import type { DataNameMappings } from "./types.js";
3
+ /**
4
+ * Names as the platform's `nameMappings` keep them: each table under the class name its generated client sends
5
+ * (`createTableClient('Orders')`), each field under its own.
6
+ */
7
+ export declare const nameMappingsOf: (names: SchemaNames) => DataNameMappings;
@@ -0,0 +1,15 @@
1
+ import { toPascalCase } from "../../sync/sdkNames.js";
2
+ /**
3
+ * Names as the platform's `nameMappings` keep them: each table under the class name its generated client sends
4
+ * (`createTableClient('Orders')`), each field under its own.
5
+ */
6
+ export const nameMappingsOf = (names) => ({
7
+ mapping: { sdkName: "Database" },
8
+ tables: Object.fromEntries(names.tables.map((table) => [
9
+ table.id,
10
+ {
11
+ mapping: { sdkName: toPascalCase(table.sdkName) },
12
+ fields: Object.fromEntries(table.fields.map((field) => [field.id, { mapping: { sdkName: field.sdkName } }])),
13
+ },
14
+ ])),
15
+ });
@@ -56,8 +56,11 @@ export interface DatabaseRecord {
56
56
  id: string;
57
57
  [key: string]: unknown;
58
58
  }
59
- /** The build's tables' and fields' SDK names, by id (`projectConfig.nameMappings`). */
59
+ /** The build's tables' and fields' SDK names, by id, as `projectConfig.nameMappings` keeps them. */
60
60
  export type DataNameMappings = {
61
+ mapping?: {
62
+ sdkName: string;
63
+ };
61
64
  tables: Record<string, {
62
65
  mapping: {
63
66
  sdkName: string;
@@ -1,4 +1,4 @@
1
- import type { HostRequestState, PagePlan, PlatformCallInput, PlatformCallResult, PlatformSession, PlatformUrls } from "./types.js";
1
+ import type { HostRequestState, PagePlan, PlatformCallInput, PlatformCallResult, PlatformUrls } from "./types.js";
2
2
  export type DirectAccess = {
3
3
  token: string;
4
4
  urls: PlatformUrls;
@@ -7,14 +7,18 @@ type Connection = Record<string, unknown> & {
7
7
  status?: unknown;
8
8
  message?: unknown;
9
9
  userFacingMessage?: unknown;
10
+ connectUrl?: unknown;
10
11
  };
11
12
  type Connections = {
12
13
  connections: Record<string, Connection>;
13
14
  env: Record<string, string>;
14
15
  envConnections: Record<string, string>;
15
16
  };
16
- export declare const sessionOf: (host: HostRequestState) => Promise<PlatformSession | undefined>;
17
- /** The request's token and where to send it, renewed first if it's about to expire; undefined on the relay. */
17
+ /** Thrown for a platform call on a request that has no token or no platform URLs. */
18
+ export declare class NoPlatformError extends Error {
19
+ constructor();
20
+ }
21
+ /** The request's token and where to send it, renewed first if it's about to expire; undefined without either. */
18
22
  export declare const directAccess: (host: HostRequestState) => Promise<DirectAccess | undefined>;
19
23
  /** At most `max` at once, the rest in turn; each take resolves with its release. */
20
24
  export declare const limiter: (max: number) => () => Promise<() => void>;
@@ -24,17 +28,17 @@ export declare const directDataFetch: (host: HostRequestState) => ({ method, pat
24
28
  path: string;
25
29
  body?: string;
26
30
  }) => Promise<Response>;
27
- /** `GET connections` for `local`, which has no host to hand them over in props. Stale if the backend didn't answer. */
28
- export declare const localConnections: (access: DirectAccess) => Promise<Connections>;
31
+ /**
32
+ * The backend's `GET connections` on the token, once per reuse window: all `local` has, and what an app on Zite asks
33
+ * when the host didn't hand them over. Stale if the backend didn't answer.
34
+ */
35
+ export declare const connectionsOnToken: (access: DirectAccess) => Promise<Connections>;
29
36
  /** The build's page settings for `local`, which has no host to send them; null when the backend has none to give. */
30
37
  export declare const localPagePlan: (access: DirectAccess) => Promise<PagePlan | null>;
31
38
  /** For tests: forget what this isolate learned. */
32
39
  export declare const resetLocalConnections: () => void;
33
- /**
34
- * A platform call on the token: undefined without one, or for a call only the host's session answers (`ZiteMeta`,
35
- * and `integrations.get` on Zite). Errors come back as values, as the relay's do.
36
- */
37
- export declare const directCall: (host: HostRequestState, input: PlatformCallInput) => Promise<PlatformCallResult | undefined>;
38
- /** After a provider answered 401: the connection refreshed by the backend, or by the host's session without a token. */
39
- export declare const refreshConnection: (host: HostRequestState, name: string) => Promise<PlatformCallResult | undefined>;
40
+ /** A platform call on the token; a throw without one. Errors come back as values, as the relay's did. */
41
+ export declare const directCall: (host: HostRequestState, input: PlatformCallInput) => Promise<PlatformCallResult>;
42
+ /** After a provider answered 401: the connection refreshed by the backend. */
43
+ export declare const refreshConnection: (host: HostRequestState, name: string) => Promise<PlatformCallResult>;
40
44
  export {};