@databricks/appkit-ui 0.96.0 → 0.97.0
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/CLAUDE.md +16 -7
- package/dist/js/database/client.d.ts +2 -2
- package/dist/js/database/client.js +1 -1
- package/dist/js/database/client.js.map +1 -1
- package/dist/react/beta.d.ts +2 -2
- package/dist/react/beta.js +1 -2
- package/dist/react/hooks/use-database-list.d.ts +4 -4
- package/dist/react/hooks/use-database-list.d.ts.map +1 -1
- package/dist/react/hooks/use-database-list.js +1 -2
- package/dist/react/hooks/use-database-list.js.map +1 -1
- package/dist/react/hooks/use-database-read.d.ts +4 -41
- package/dist/react/hooks/use-database-read.d.ts.map +1 -1
- package/dist/react/hooks/use-database-read.js +7 -68
- package/dist/react/hooks/use-database-read.js.map +1 -1
- package/dist/react/hooks/use-database-record.d.ts +3 -3
- package/dist/react/hooks/use-database-record.d.ts.map +1 -1
- package/dist/react/hooks/use-database-record.js +2 -3
- package/dist/react/hooks/use-database-record.js.map +1 -1
- package/dist/react/hooks/use-database-write.d.ts +3 -3
- package/dist/react/hooks/use-database-write.js.map +1 -1
- package/dist/shared/src/database/api-types.d.ts +1 -4
- package/dist/shared/src/database/api-types.d.ts.map +1 -1
- package/dist/shared/src/database/index.d.ts +3 -0
- package/dist/shared/src/database/operations.d.ts +11 -0
- package/dist/shared/src/database/operations.d.ts.map +1 -0
- package/dist/shared/src/index.d.ts +1 -0
- package/docs/api/appkit/Class.DatabaseValidationError.md +1 -1
- package/docs/api/appkit/Function.defineOperation.md +61 -0
- package/docs/api/appkit/Function.definePolicy.md +52 -0
- package/docs/api/appkit/Function.defineSchema.md +1 -1
- package/docs/api/appkit/Interface.Actor.md +21 -0
- package/docs/api/appkit/Interface.DatabaseOperationContract.md +30 -0
- package/docs/api/appkit/Interface.DatabaseRoutes.md +30 -0
- package/docs/api/appkit/Interface.OperationContext.md +75 -0
- package/docs/api/appkit/Interface.OperationDefinition.md +77 -0
- package/docs/api/appkit/Interface.PolicyContext.md +49 -0
- package/docs/api/appkit/Interface.PolicyDenial.md +21 -0
- package/docs/api/appkit/TypeAlias.DatabricksAppKitDatabaseOperations.md +8 -0
- package/docs/api/appkit/TypeAlias.IDatabaseConfig.md +0 -10
- package/docs/api/appkit/TypeAlias.OperationMethod.md +8 -0
- package/docs/api/appkit/TypeAlias.OperationWireInput.md +14 -0
- package/docs/api/appkit/TypeAlias.OperationWireOutput.md +14 -0
- package/docs/api/appkit/TypeAlias.Policy.md +15 -0
- package/docs/api/appkit/TypeAlias.PolicyDecision.md +8 -0
- package/docs/api/appkit.md +60 -51
- package/docs/plugins/database.md +17 -70
- package/llms.txt +16 -7
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
- package/docs/api/appkit/Interface.EntityMutationHooks.md +0 -173
- package/docs/api/appkit/Interface.HookApp.md +0 -12
- package/docs/api/appkit/Interface.HookContext.md +0 -21
- package/docs/api/appkit/Interface.ReadSerializerContext.md +0 -21
- package/docs/api/appkit/TypeAlias.EntityHooks.md +0 -25
- package/docs/api/appkit/TypeAlias.ReadSerializer.md +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-database-record.js","names":[],"sources":["../../../src/react/hooks/use-database-record.ts"],"sourcesContent":["import {\n DatabaseQueryEncodingError,\n encodeDatabaseRecordQuery,\n type ExactDatabaseParams,\n} from \"shared\";\n\nimport { isDatabaseRow } from \"@/js/database/client\";\nimport type {\n DatabaseId,\n DatabaseKeyedEntity,\n DatabaseRecordParams,\n DatabaseRecordRow,\n} from \"@/js/database/types\";\n\nimport {\n type DatabaseReadRequest,\n type UseDatabaseReadOptions,\n type UseDatabaseReadResult,\n useDatabaseRead,\n} from \"./use-database-read\";\n\n/** Options for {@link useDatabaseRecord}. */\nexport type UseDatabaseRecordOptions
|
|
1
|
+
{"version":3,"file":"use-database-record.js","names":[],"sources":["../../../src/react/hooks/use-database-record.ts"],"sourcesContent":["import {\n DatabaseQueryEncodingError,\n encodeDatabaseRecordQuery,\n type ExactDatabaseParams,\n} from \"shared\";\n\nimport { isDatabaseRow } from \"@/js/database/client\";\nimport type {\n DatabaseId,\n DatabaseKeyedEntity,\n DatabaseRecordParams,\n DatabaseRecordRow,\n} from \"@/js/database/types\";\n\nimport {\n type DatabaseReadRequest,\n type UseDatabaseReadOptions,\n type UseDatabaseReadResult,\n useDatabaseRead,\n} from \"./use-database-read\";\n\n/** Options for {@link useDatabaseRecord}. */\nexport type UseDatabaseRecordOptions = UseDatabaseReadOptions;\n\n/** What {@link useDatabaseRecord} returns: one row and its state. */\nexport type UseDatabaseRecordResult<Row> = UseDatabaseReadResult<Row>;\n\n/**\n * Subscribe to one row from `GET /api/database/<entity>/:id`. Only entities\n * with a public primary key have this route; a missing row surfaces as a\n * `NOT_FOUND` error, and a refetch that finds the row gone clears `data`.\n *\n * A `null` or `undefined` id holds the hook idle without a request, so a\n * record that depends on another read needs no separate `enabled` flag. An\n * empty, `\".\"`, or `\"..\"` id reports `INVALID_REQUEST` without a request.\n *\n * @param entity - A table the generated registry exposes with a public key\n * @param id - The row's public key, or `null`/`undefined` to wait\n * @param params - `select` and `include`; pass `{}` to reach `options` alone\n * @param options - `enabled` and `keepPreviousData`\n * @returns The row, loading and error state, and `refetch`\n *\n * @example\n * ```tsx\n * const board = useDatabaseRecord(\"boards\", selectedId, {\n * include: { notes: { limit: 20 } },\n * });\n * board.data?.notes.length;\n * ```\n */\nexport function useDatabaseRecord<\n K extends DatabaseKeyedEntity,\n const P extends DatabaseRecordParams<K> = Record<never, never>,\n>(\n entity: K,\n id: DatabaseId<K> | null | undefined,\n params?: P & ExactDatabaseParams<P, DatabaseRecordParams<K>>,\n options: UseDatabaseRecordOptions = {},\n): UseDatabaseRecordResult<DatabaseRecordRow<K, P>> {\n const enabled = (options.enabled ?? true) && id !== null && id !== undefined;\n const recordParams = (params ?? {}) as { include?: unknown };\n // Encode only an enabled read: a held read's params may still be incomplete.\n let query: DatabaseReadRequest[\"query\"] = \"\";\n if (enabled) {\n try {\n query = encodeDatabaseRecordQuery(recordParams);\n } catch (error) {\n query = error instanceof DatabaseQueryEncodingError ? error : null;\n }\n }\n const read = useDatabaseRead({\n entity,\n operation: \"detail\",\n id: id ?? undefined,\n query,\n include: recordParams.include,\n enabled,\n accept: isDatabaseRow,\n keepPreviousData: options.keepPreviousData ?? false,\n });\n // The server projected and encoded the row; the types describe that wire.\n return read as UseDatabaseRecordResult<DatabaseRecordRow<K, P>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,kBAId,QACA,IACA,QACA,UAAoC,EAAE,EACY;CAClD,MAAM,WAAW,QAAQ,WAAW,SAAS,OAAO,QAAQ,OAAO;CACnE,MAAM,eAAgB,UAAU,EAAE;CAElC,IAAI,QAAsC;AAC1C,KAAI,QACF,KAAI;AACF,UAAQ,0BAA0B,aAAa;UACxC,OAAO;AACd,UAAQ,iBAAiB,6BAA6B,QAAQ;;AAclE,QAXa,gBAAgB;EAC3B;EACA,WAAW;EACX,IAAI,MAAM;EACV;EACA,SAAS,aAAa;EACtB;EACA,QAAQ;EACR,kBAAkB,QAAQ,oBAAoB;EAC/C,CAAC"}
|
|
@@ -21,9 +21,9 @@ interface UseDatabaseWriteState<T> {
|
|
|
21
21
|
interface UseDatabaseWriteOptions {
|
|
22
22
|
/**
|
|
23
23
|
* Reads to restart once a write succeeds. Default `true`: every mounted
|
|
24
|
-
* database read, since a
|
|
25
|
-
*
|
|
26
|
-
* directly or through an include; `false` restarts none.
|
|
24
|
+
* database read, since a foreign key declared with `onDelete("cascade")` can
|
|
25
|
+
* change other tables too. A table list restarts only the reads that show
|
|
26
|
+
* those tables, directly or through an include; `false` restarts none.
|
|
27
27
|
*/
|
|
28
28
|
invalidate?: DatabaseInvalidation;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-database-write.js","names":[],"sources":["../../../src/react/hooks/use-database-write.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { DatabaseApiError } from \"@/js/database/errors\";\n\nimport {\n asDatabaseApiError,\n type DatabaseInvalidation,\n invalidateDatabaseReads,\n} from \"./database-request-store\";\n\nexport type { DatabaseInvalidation } from \"./database-request-store\";\n\n/** Latest state of a database write hook. */\nexport interface UseDatabaseWriteState<T> {\n /** The latest call's result, or `null` before it answers. */\n data: T | null;\n /**\n * Whether the latest call is in flight, including the reload of the reads\n * it restarts.\n */\n loading: boolean;\n /**\n * Why the latest call failed: `NOT_EXPOSED` when no route exists,\n * `OUTCOME_UNKNOWN` when it may have committed without an answer.\n */\n error: DatabaseApiError | null;\n}\n\n/** Options every database write hook takes. */\nexport interface UseDatabaseWriteOptions {\n /**\n * Reads to restart once a write succeeds. Default `true`: every mounted\n * database read, since a
|
|
1
|
+
{"version":3,"file":"use-database-write.js","names":[],"sources":["../../../src/react/hooks/use-database-write.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { DatabaseApiError } from \"@/js/database/errors\";\n\nimport {\n asDatabaseApiError,\n type DatabaseInvalidation,\n invalidateDatabaseReads,\n} from \"./database-request-store\";\n\nexport type { DatabaseInvalidation } from \"./database-request-store\";\n\n/** Latest state of a database write hook. */\nexport interface UseDatabaseWriteState<T> {\n /** The latest call's result, or `null` before it answers. */\n data: T | null;\n /**\n * Whether the latest call is in flight, including the reload of the reads\n * it restarts.\n */\n loading: boolean;\n /**\n * Why the latest call failed: `NOT_EXPOSED` when no route exists,\n * `OUTCOME_UNKNOWN` when it may have committed without an answer.\n */\n error: DatabaseApiError | null;\n}\n\n/** Options every database write hook takes. */\nexport interface UseDatabaseWriteOptions {\n /**\n * Reads to restart once a write succeeds. Default `true`: every mounted\n * database read, since a foreign key declared with `onDelete(\"cascade\")` can\n * change other tables too. A table list restarts only the reads that show\n * those tables, directly or through an include; `false` restarts none.\n */\n invalidate?: DatabaseInvalidation;\n}\n\n/** The generic write lifecycle's callbacks, before each hook names its args. */\ninterface WriteCallbacks<Args extends unknown[], T> {\n invalidate?: DatabaseInvalidation;\n onSuccess?: (data: T, args: Args) => void;\n onError?: (error: DatabaseApiError, args: Args) => void;\n}\n\ninterface DatabaseWrite<\n Args extends unknown[],\n T,\n> extends UseDatabaseWriteState<T> {\n mutate(...args: Args): Promise<T | null>;\n reset(): void;\n}\n\nconst IDLE: UseDatabaseWriteState<never> = Object.freeze({\n data: null,\n loading: false,\n error: null,\n});\n\n/**\n * Run a caller's callback without letting it break the write's promise: the\n * call still resolves, and the exception still reaches the page's error\n * handling (and any error tracker) as an uncaught error.\n */\nfunction runCallback(callback: () => void): void {\n try {\n callback();\n } catch (error) {\n if (typeof globalThis.reportError === \"function\") {\n globalThis.reportError(error);\n } else {\n setTimeout(() => {\n throw error;\n });\n }\n }\n}\n\n/**\n * One write hook's state around `send`, which must be stable per entity.\n *\n * A call never rejects, like `useServingInvoke`: it resolves with the result,\n * or with `null` once the failure is in `error`, so a handler needs no\n * `try/catch`. Callers that want an exception use `databaseApi` directly.\n *\n * A write is never aborted: cancelling the request would not undo a committed\n * transaction. A successful call restarts the reads `invalidate` names and\n * resolves once they have reloaded, so a handler that clears its form sees the\n * new rows already on screen. Only the latest call of a hook updates its\n * state; callbacks run for every call, even after the hook unmounts, since the\n * rows did change.\n */\nexport function useDatabaseWrite<Args extends unknown[], T>(\n send: (...args: Args) => Promise<T>,\n options: WriteCallbacks<Args, T>,\n): DatabaseWrite<Args, T> {\n const [state, setState] = useState<UseDatabaseWriteState<T>>(IDLE);\n const latest = useRef<symbol | null>(null);\n\n // Read at call time, so inline callbacks and an inline `invalidate` list do\n // not change `mutate`'s identity on every render.\n const optionsRef = useRef(options);\n useEffect(() => {\n optionsRef.current = options;\n });\n\n const mutate = useCallback(\n async (...args: Args): Promise<T | null> => {\n const call = Symbol(\"database write\");\n latest.current = call;\n // React ignores a state update after unmount, so only staleness matters.\n const settle = (next: UseDatabaseWriteState<T>) => {\n if (latest.current === call) setState(next);\n };\n\n settle({ data: null, loading: true, error: null });\n let data: T;\n try {\n data = await send(...args);\n } catch (cause) {\n const error = asDatabaseApiError(cause);\n settle({ data: null, loading: false, error });\n const { onError } = optionsRef.current;\n if (onError) runCallback(() => onError(error, args));\n return null;\n }\n // Hold `loading` until the restarted reads answer, so the hook does not\n // report success beside rows that still show the old state.\n await invalidateDatabaseReads(optionsRef.current.invalidate ?? true);\n settle({ data, loading: false, error: null });\n const { onSuccess } = optionsRef.current;\n if (onSuccess) runCallback(() => onSuccess(data, args));\n return data;\n },\n [send],\n );\n\n // A call still in flight keeps running, but no longer reports here.\n const reset = useCallback(() => {\n latest.current = null;\n setState(IDLE);\n }, []);\n\n return { ...state, mutate, reset };\n}\n"],"mappings":";;;;AAsDA,MAAM,OAAqC,OAAO,OAAO;CACvD,MAAM;CACN,SAAS;CACT,OAAO;CACR,CAAC;;;;;;AAOF,SAAS,YAAY,UAA4B;AAC/C,KAAI;AACF,YAAU;UACH,OAAO;AACd,MAAI,OAAO,WAAW,gBAAgB,WACpC,YAAW,YAAY,MAAM;MAE7B,kBAAiB;AACf,SAAM;IACN;;;;;;;;;;;;;;;;;AAmBR,SAAgB,iBACd,MACA,SACwB;CACxB,MAAM,CAAC,OAAO,YAAY,SAAmC,KAAK;CAClE,MAAM,SAAS,OAAsB,KAAK;CAI1C,MAAM,aAAa,OAAO,QAAQ;AAClC,iBAAgB;AACd,aAAW,UAAU;GACrB;CAEF,MAAM,SAAS,YACb,OAAO,GAAG,SAAkC;EAC1C,MAAM,OAAO,OAAO,iBAAiB;AACrC,SAAO,UAAU;EAEjB,MAAM,UAAU,SAAmC;AACjD,OAAI,OAAO,YAAY,KAAM,UAAS,KAAK;;AAG7C,SAAO;GAAE,MAAM;GAAM,SAAS;GAAM,OAAO;GAAM,CAAC;EAClD,IAAI;AACJ,MAAI;AACF,UAAO,MAAM,KAAK,GAAG,KAAK;WACnB,OAAO;GACd,MAAM,QAAQ,mBAAmB,MAAM;AACvC,UAAO;IAAE,MAAM;IAAM,SAAS;IAAO;IAAO,CAAC;GAC7C,MAAM,EAAE,YAAY,WAAW;AAC/B,OAAI,QAAS,mBAAkB,QAAQ,OAAO,KAAK,CAAC;AACpD,UAAO;;AAIT,QAAM,wBAAwB,WAAW,QAAQ,cAAc,KAAK;AACpE,SAAO;GAAE;GAAM,SAAS;GAAO,OAAO;GAAM,CAAC;EAC7C,MAAM,EAAE,cAAc,WAAW;AACjC,MAAI,UAAW,mBAAkB,UAAU,MAAM,KAAK,CAAC;AACvD,SAAO;IAET,CAAC,KAAK,CACP;CAGD,MAAM,QAAQ,kBAAkB;AAC9B,SAAO,UAAU;AACjB,WAAS,KAAK;IACb,EAAE,CAAC;AAEN,QAAO;EAAE,GAAG;EAAO;EAAQ;EAAO"}
|
|
@@ -103,10 +103,7 @@ type RecordRowFor<R, K, P> = ListRowFor<R, K, P>;
|
|
|
103
103
|
type InsertFor<R, K> = WireInput<ApiOf<R, K>["insert"]>;
|
|
104
104
|
/** The body a generated update route accepts for `K`, as JSON carries it. */
|
|
105
105
|
type UpdateFor<R, K> = WireInput<ApiOf<R, K>["update"]>;
|
|
106
|
-
/**
|
|
107
|
-
* The public row a generated create or update route answers with. A read
|
|
108
|
-
* serializer never reshapes a write's response, so this is always the row.
|
|
109
|
-
*/
|
|
106
|
+
/** The public row a generated create or update route answers with. */
|
|
110
107
|
type PublicRowFor<R, K> = WireOutput<PublicRowOf<R, K>>;
|
|
111
108
|
/** The envelope a generated list route answers with. */
|
|
112
109
|
interface DatabaseListPage<Row> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-types.d.ts","names":[],"sources":["../../../../../shared/src/database/api-types.ts"],"mappings":";;AAOA;;;;;UAAiB,gBAAA;EAIN;EAAA,SAFA,SAAA,EAAW,MAAA;EAIX;EAAA,SAFA,QAAA,EAAU,MAAA;EAIR;EAAA,SAFF,GAAA;IAAA,SACE,MAAA;IAAA,SACA,MAAA;IAAA,SACA,OAAA,UAIG;I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{ DatabaseApiEntityFor, DatabaseApiEntry, DatabaseListPage, ExactDatabaseParams, HttpIncludeArgFor, IdFor, InsertFor, KeyedEntityFor, ListParamsFor, ListRowFor, PublicRowFor, RecordParamsFor, RecordRowFor, UpdateFor, WireInput, WireOutput } from "./api-types.js";
|
|
2
|
+
import { DatabaseErrorCategory, DatabaseErrorDetail } from "./errors.js";
|
|
3
|
+
import "./operations.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region ../shared/src/database/operations.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Names the UI resolves without importing a server module. Empty until
|
|
4
|
+
* generation adds one entry per operation name. The declaration is global so
|
|
5
|
+
* a generated `database.d.ts` can augment it without importing this module.
|
|
6
|
+
*/
|
|
7
|
+
declare global {
|
|
8
|
+
interface DatabricksAppKitDatabaseOperations {}
|
|
9
|
+
}
|
|
10
|
+
/** The same global registry, available as a module type for package exports. */
|
|
11
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","names":[],"sources":["../../../../../shared/src/database/operations.ts"],"mappings":";;;;;;QAuBQ,MAAA;EAAA,UAEI,kCAAA;AAAA"}
|
|
@@ -5,6 +5,7 @@ import { PluginClientConfigs, PluginEndpointMap, PluginEndpoints } from "./plugi
|
|
|
5
5
|
import "./cache.js";
|
|
6
6
|
import { DatabaseApiEntityFor, DatabaseApiEntry, DatabaseListPage, ExactDatabaseParams, HttpIncludeArgFor, IdFor, InsertFor, KeyedEntityFor, ListParamsFor, ListRowFor, PublicRowFor, RecordParamsFor, RecordRowFor, UpdateFor, WireInput, WireOutput } from "./database/api-types.js";
|
|
7
7
|
import { DatabaseErrorCategory, DatabaseErrorDetail } from "./database/errors.js";
|
|
8
|
+
import "./database/index.js";
|
|
8
9
|
import { GenieAttachmentResponse, GenieMessageResponse, GenieStatementResponse, GenieStreamEvent } from "./genie.js";
|
|
9
10
|
import { MetricFilter, MetricFilterOperatorName, MetricOrderBy, MetricOrderDirection, MetricPredicate } from "./metric-filter.js";
|
|
10
11
|
import { MetricViewColumnDisplay } from "./metric-metadata.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: DatabaseValidationError
|
|
2
2
|
|
|
3
|
-
Deliberate validation failure
|
|
3
|
+
Deliberate validation failure. An explicit transaction callback can throw it, and the transaction rethrows that same error. Generated routes answer `422` and echo only the issues naming a public column. Every other failure stays an opaque server error.
|
|
4
4
|
|
|
5
5
|
## Extends[](#extends "Direct link to Extends")
|
|
6
6
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Function: defineOperation()
|
|
2
|
+
|
|
3
|
+
## Call Signature[](#call-signature "Direct link to Call Signature")
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function defineOperation<Name, M, I, O, R>(definition: OperationFields<M, I, O, Name> & {
|
|
7
|
+
authorize: ResourcePolicy<ParsedInput<I>, R>;
|
|
8
|
+
execute: (context: OperationContext<ParsedInput<I>, NonNullable<Awaited<R>>>) => Awaitable<ExecuteResult<M, O>>;
|
|
9
|
+
}): OperationDefinition<M, I, O, R, Name>;
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Declare one database operation. `name` is its public identifier. Declare an `input` Zod schema to accept parameters; without one, callbacks receive `undefined`. Declare an `output` Zod schema to answer a body; without one, the operation answers none. Definition only freezes a descriptor.
|
|
14
|
+
|
|
15
|
+
### Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
16
|
+
|
|
17
|
+
| Type Parameter |
|
|
18
|
+
| --------------------------------------- |
|
|
19
|
+
| `Name` *extends* `string` |
|
|
20
|
+
| `M` *extends* `DatabaseOperationMethod` |
|
|
21
|
+
| `I` *extends* `SchemaSlot` |
|
|
22
|
+
| `O` *extends* `SchemaSlot` |
|
|
23
|
+
| `R` *extends* { } |
|
|
24
|
+
|
|
25
|
+
### Parameters[](#parameters "Direct link to Parameters")
|
|
26
|
+
|
|
27
|
+
| Parameter | Type |
|
|
28
|
+
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| `definition` | `OperationFields`<`M`, `I`, `O`, `Name`> & { `authorize`: `ResourcePolicy`<`ParsedInput`<`I`>, `R`>; `execute`: (`context`: [`OperationContext`](./docs/api/appkit/Interface.OperationContext.md)<`ParsedInput`<`I`>, `NonNullable`<`Awaited`<`R`>>>) => `Awaitable`<`ExecuteResult`<`M`, `O`>>; } |
|
|
30
|
+
|
|
31
|
+
### Returns[](#returns "Direct link to Returns")
|
|
32
|
+
|
|
33
|
+
[`OperationDefinition`](./docs/api/appkit/Interface.OperationDefinition.md)<`M`, `I`, `O`, `R`, `Name`>
|
|
34
|
+
|
|
35
|
+
## Call Signature[](#call-signature-1 "Direct link to Call Signature")
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
function defineOperation<Name, M, I, O>(definition: OperationOptions<M, I, O, undefined, Name>): OperationDefinition<M, I, O, undefined, Name>;
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Declare one database operation. `name` is its public identifier. Declare an `input` Zod schema to accept parameters; without one, callbacks receive `undefined`. Declare an `output` Zod schema to answer a body; without one, the operation answers none. Definition only freezes a descriptor.
|
|
43
|
+
|
|
44
|
+
### Type Parameters[](#type-parameters-1 "Direct link to Type Parameters")
|
|
45
|
+
|
|
46
|
+
| Type Parameter | Default type |
|
|
47
|
+
| --------------------------------------- | ------------ |
|
|
48
|
+
| `Name` *extends* `string` | - |
|
|
49
|
+
| `M` *extends* `DatabaseOperationMethod` | - |
|
|
50
|
+
| `I` *extends* `SchemaSlot` | `undefined` |
|
|
51
|
+
| `O` *extends* `SchemaSlot` | `undefined` |
|
|
52
|
+
|
|
53
|
+
### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
54
|
+
|
|
55
|
+
| Parameter | Type |
|
|
56
|
+
| ------------ | ------------------------------------------------------ |
|
|
57
|
+
| `definition` | `OperationOptions`<`M`, `I`, `O`, `undefined`, `Name`> |
|
|
58
|
+
|
|
59
|
+
### Returns[](#returns-1 "Direct link to Returns")
|
|
60
|
+
|
|
61
|
+
[`OperationDefinition`](./docs/api/appkit/Interface.OperationDefinition.md)<`M`, `I`, `O`, `undefined`, `Name`>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Function: definePolicy()
|
|
2
|
+
|
|
3
|
+
## Call Signature[](#call-signature "Direct link to Call Signature")
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function definePolicy<In>(policy: AllowPolicy<In>): AllowPolicy<In>;
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Declare a reusable authorization rule. Without `resource` it decides from the actor and input. With `resource` it loads one record first, from the same context every callback receives, `actor` included; annotate the lookup context to fix the input the policy needs. `allow` may return `true`, `false`, or `{ deny }`.
|
|
11
|
+
|
|
12
|
+
### Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
13
|
+
|
|
14
|
+
| Type Parameter | Default type |
|
|
15
|
+
| -------------- | ------------ |
|
|
16
|
+
| `In` | `unknown` |
|
|
17
|
+
|
|
18
|
+
### Parameters[](#parameters "Direct link to Parameters")
|
|
19
|
+
|
|
20
|
+
| Parameter | Type |
|
|
21
|
+
| --------- | ------------------- |
|
|
22
|
+
| `policy` | `AllowPolicy`<`In`> |
|
|
23
|
+
|
|
24
|
+
### Returns[](#returns "Direct link to Returns")
|
|
25
|
+
|
|
26
|
+
`AllowPolicy`<`In`>
|
|
27
|
+
|
|
28
|
+
## Call Signature[](#call-signature-1 "Direct link to Call Signature")
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
function definePolicy<In, R>(policy: ResourcePolicy<In, R>): ResourcePolicy<In, R>;
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Declare a reusable authorization rule. Without `resource` it decides from the actor and input. With `resource` it loads one record first, from the same context every callback receives, `actor` included; annotate the lookup context to fix the input the policy needs. `allow` may return `true`, `false`, or `{ deny }`.
|
|
36
|
+
|
|
37
|
+
### Type Parameters[](#type-parameters-1 "Direct link to Type Parameters")
|
|
38
|
+
|
|
39
|
+
| Type Parameter |
|
|
40
|
+
| -------------- |
|
|
41
|
+
| `In` |
|
|
42
|
+
| `R` |
|
|
43
|
+
|
|
44
|
+
### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
45
|
+
|
|
46
|
+
| Parameter | Type |
|
|
47
|
+
| --------- | --------------------------- |
|
|
48
|
+
| `policy` | `ResourcePolicy`<`In`, `R`> |
|
|
49
|
+
|
|
50
|
+
### Returns[](#returns-1 "Direct link to Returns")
|
|
51
|
+
|
|
52
|
+
`ResourcePolicy`<`In`, `R`>
|
|
@@ -5,7 +5,7 @@ function defineSchema<TTables>(builder: (context: SchemaBuilderContext) => TTabl
|
|
|
5
5
|
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
Compile one declared schema. The returned type keeps the table names the builder returned, so `api.tables`
|
|
8
|
+
Compile one declared schema. The returned type keeps the table names the builder returned, so `api.tables` can name only real tables.
|
|
9
9
|
|
|
10
10
|
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
11
11
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: Actor
|
|
2
|
+
|
|
3
|
+
The authenticated caller. The HTTP boundary resolves it before any policy runs.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### email?[](#email "Direct link to email?")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly optional email: string;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### id[](#id "Direct link to id")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly id: string;
|
|
20
|
+
|
|
21
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Interface: DatabaseOperationContract
|
|
2
|
+
|
|
3
|
+
The browser-safe contract of one generated operation. `input` and `output` are JSON types. A generated `database.d.ts` fills this interface by name.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### input[](#input "Direct link to input")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly input: unknown;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### method[](#method "Direct link to method")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly method: DatabaseOperationMethod;
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### output[](#output "Direct link to output")
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
readonly output: unknown;
|
|
29
|
+
|
|
30
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Interface: DatabaseRoutes
|
|
2
|
+
|
|
3
|
+
The generated route entry. `schema` and each module stay lazy, so importing the registry evaluates neither the schema nor an operation.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### modules[](#modules "Direct link to modules")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly modules: readonly {
|
|
11
|
+
file: string;
|
|
12
|
+
load: () => Promise<Record<string, unknown>>;
|
|
13
|
+
}[];
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
19
|
+
### schema()[](#schema "Direct link to schema()")
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
readonly schema: () => Promise<{
|
|
23
|
+
schema: Schema;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
29
|
+
|
|
30
|
+
`Promise`<{ `schema`: [`Schema`](./docs/api/appkit/Interface.Schema.md); }>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Interface: OperationContext\<In, R>
|
|
2
|
+
|
|
3
|
+
What `allow` and `execute` receive: the policy context and the loaded resource.
|
|
4
|
+
|
|
5
|
+
## Extends[](#extends "Direct link to Extends")
|
|
6
|
+
|
|
7
|
+
* [`PolicyContext`](./docs/api/appkit/Interface.PolicyContext.md)<`In`>
|
|
8
|
+
|
|
9
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
10
|
+
|
|
11
|
+
| Type Parameter | Default type |
|
|
12
|
+
| -------------- | ------------ |
|
|
13
|
+
| `In` | `unknown` |
|
|
14
|
+
| `R` | `undefined` |
|
|
15
|
+
|
|
16
|
+
## Properties[](#properties "Direct link to Properties")
|
|
17
|
+
|
|
18
|
+
### actor[](#actor "Direct link to actor")
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
readonly actor: Actor;
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### Inherited from[](#inherited-from "Direct link to Inherited from")
|
|
26
|
+
|
|
27
|
+
[`PolicyContext`](./docs/api/appkit/Interface.PolicyContext.md).[`actor`](./docs/api/appkit/Interface.PolicyContext.md#actor)
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### appkit[](#appkit "Direct link to appkit")
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
readonly appkit: OperationAppKit;
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Inherited from[](#inherited-from-1 "Direct link to Inherited from")
|
|
39
|
+
|
|
40
|
+
[`PolicyContext`](./docs/api/appkit/Interface.PolicyContext.md).[`appkit`](./docs/api/appkit/Interface.PolicyContext.md#appkit)
|
|
41
|
+
|
|
42
|
+
***
|
|
43
|
+
|
|
44
|
+
### db[](#db "Direct link to db")
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
readonly db: DatabaseExports;
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### Inherited from[](#inherited-from-2 "Direct link to Inherited from")
|
|
52
|
+
|
|
53
|
+
[`PolicyContext`](./docs/api/appkit/Interface.PolicyContext.md).[`db`](./docs/api/appkit/Interface.PolicyContext.md#db)
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### input[](#input "Direct link to input")
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
readonly input: In;
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Inherited from[](#inherited-from-3 "Direct link to Inherited from")
|
|
65
|
+
|
|
66
|
+
[`PolicyContext`](./docs/api/appkit/Interface.PolicyContext.md).[`input`](./docs/api/appkit/Interface.PolicyContext.md#input)
|
|
67
|
+
|
|
68
|
+
***
|
|
69
|
+
|
|
70
|
+
### resource[](#resource "Direct link to resource")
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
readonly resource: R;
|
|
74
|
+
|
|
75
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Interface: OperationDefinition\<M, I, O, R, Name>
|
|
2
|
+
|
|
3
|
+
One immutable operation descriptor. Nothing in it runs until a request does.
|
|
4
|
+
|
|
5
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
6
|
+
|
|
7
|
+
| Type Parameter |
|
|
8
|
+
| --------------------------------------------------------------------------------------- |
|
|
9
|
+
| `M` *extends* [`OperationMethod`](./docs/api/appkit/TypeAlias.OperationMethod.md) |
|
|
10
|
+
| `I` *extends* `SchemaSlot` |
|
|
11
|
+
| `O` *extends* `SchemaSlot` |
|
|
12
|
+
| `R` |
|
|
13
|
+
| `Name` *extends* `string` |
|
|
14
|
+
|
|
15
|
+
## Properties[](#properties "Direct link to Properties")
|
|
16
|
+
|
|
17
|
+
### authorize[](#authorize "Direct link to authorize")
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
readonly authorize: Authorize<ParsedInput<I>, R>;
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
***
|
|
25
|
+
|
|
26
|
+
### execute()[](#execute "Direct link to execute()")
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
readonly execute: (context: OperationContext<ParsedInput<I>, [R] extends [undefined] ? undefined : NonNullable<Awaited<R>>>) => Awaitable<ExecuteResult<M, O>>;
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### Parameters[](#parameters "Direct link to Parameters")
|
|
34
|
+
|
|
35
|
+
| Parameter | Type |
|
|
36
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
37
|
+
| `context` | [`OperationContext`](./docs/api/appkit/Interface.OperationContext.md)<`ParsedInput`<`I`>, \[`R`] *extends* \[`undefined`] ? `undefined` : `NonNullable`<`Awaited`<`R`>>> |
|
|
38
|
+
|
|
39
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
40
|
+
|
|
41
|
+
`Awaitable`<`ExecuteResult`<`M`, `O`>>
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### input[](#input "Direct link to input")
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
readonly input: I;
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
***
|
|
53
|
+
|
|
54
|
+
### method[](#method "Direct link to method")
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
readonly method: M;
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
63
|
+
### name[](#name "Direct link to name")
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
readonly name: Name;
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
***
|
|
71
|
+
|
|
72
|
+
### output[](#output "Direct link to output")
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
readonly output: O;
|
|
76
|
+
|
|
77
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Interface: PolicyContext\<In>
|
|
2
|
+
|
|
3
|
+
What every authorization callback receives, the `resource` lookup included. `actor` is the verified caller, so a lookup can scope its query to them.
|
|
4
|
+
|
|
5
|
+
## Extended by[](#extended-by "Direct link to Extended by")
|
|
6
|
+
|
|
7
|
+
* [`OperationContext`](./docs/api/appkit/Interface.OperationContext.md)
|
|
8
|
+
|
|
9
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
10
|
+
|
|
11
|
+
| Type Parameter | Default type |
|
|
12
|
+
| -------------- | ------------ |
|
|
13
|
+
| `In` | `unknown` |
|
|
14
|
+
|
|
15
|
+
## Properties[](#properties "Direct link to Properties")
|
|
16
|
+
|
|
17
|
+
### actor[](#actor "Direct link to actor")
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
readonly actor: Actor;
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
***
|
|
25
|
+
|
|
26
|
+
### appkit[](#appkit "Direct link to appkit")
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
readonly appkit: OperationAppKit;
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
***
|
|
34
|
+
|
|
35
|
+
### db[](#db "Direct link to db")
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
readonly db: DatabaseExports;
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
***
|
|
43
|
+
|
|
44
|
+
### input[](#input "Direct link to input")
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
readonly input: In;
|
|
48
|
+
|
|
49
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: PolicyDenial
|
|
2
|
+
|
|
3
|
+
An explicit refusal. `reason` stays on the server; HTTP and logs do not receive it.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### deny[](#deny "Direct link to deny")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly deny: "forbidden" | "not-found";
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### reason?[](#reason "Direct link to reason?")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly optional reason: string;
|
|
20
|
+
|
|
21
|
+
```
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
```ts
|
|
4
4
|
type IDatabaseConfig<TSchema> = {
|
|
5
5
|
api?: DatabaseApiConfig<TSchema>;
|
|
6
|
-
hooks?: { readonly [TTable in SchemaTableName<TSchema>]?: EntityHooks<TTable> };
|
|
7
6
|
pool?: DatabasePoolConfig;
|
|
8
7
|
schema?: TSchema;
|
|
9
8
|
};
|
|
@@ -40,15 +39,6 @@ true
|
|
|
40
39
|
|
|
41
40
|
***
|
|
42
41
|
|
|
43
|
-
### hooks?[](#hooks "Direct link to hooks?")
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
readonly optional hooks: { readonly [TTable in SchemaTableName<TSchema>]?: EntityHooks<TTable> };
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
***
|
|
51
|
-
|
|
52
42
|
### pool?[](#pool "Direct link to pool?")
|
|
53
43
|
|
|
54
44
|
```ts
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Type Alias: OperationWireInput\<Operation>
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type OperationWireInput<Operation> = Operation extends OperationDefinition<infer _M, infer I, infer _O, infer _R, infer _Name> ? WireInputOf<I> : never;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
The JSON a caller sends to an operation; a bigint travels as a string or safe integer.
|
|
9
|
+
|
|
10
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
11
|
+
|
|
12
|
+
| Type Parameter |
|
|
13
|
+
| -------------- |
|
|
14
|
+
| `Operation` |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Type Alias: OperationWireOutput\<Operation>
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type OperationWireOutput<Operation> = Operation extends OperationDefinition<infer M, infer _I, infer O, infer _R, infer _Name> ? WireOutputOf<M, O> : never;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
The JSON a successful call answers with; without an output schema there is none.
|
|
9
|
+
|
|
10
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
11
|
+
|
|
12
|
+
| Type Parameter |
|
|
13
|
+
| -------------- |
|
|
14
|
+
| `Operation` |
|