@deepraxis/sdk 0.1.0-dev.48c1ce8 → 0.1.0-dev.4cbfc1f
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/core/client.d.ts +5 -1
- package/dist/core/client.js +3 -0
- package/dist/core/transport.d.ts +5 -0
- package/dist/core/transport.js +6 -1
- package/dist/generated/sdk.gen.d.ts +10 -10
- package/dist/generated/sdk.gen.js +10 -10
- package/dist/generated/types.gen.d.ts +52 -49
- package/dist/helpers/database-count.d.ts +17 -0
- package/dist/helpers/database-count.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/operations.generated.d.ts +27 -27
- package/dist/operations.generated.js +27 -27
- package/dist/resources.generated.d.ts +7 -7
- package/package.json +1 -1
package/dist/core/client.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { resourceFactories } from '../resources.generated.js';
|
|
2
2
|
import { type PraxisOptions } from './transport.js';
|
|
3
3
|
import { type PublishInput, type PublishResult } from '../helpers/application-publish.js';
|
|
4
|
+
import { type CountInput, type CountResult } from '../helpers/database-count.js';
|
|
4
5
|
type Resources = {
|
|
5
6
|
readonly [K in keyof typeof resourceFactories]: ReturnType<(typeof resourceFactories)[K]>;
|
|
6
7
|
};
|
|
7
|
-
export interface Praxis extends Omit<Resources, 'application'> {
|
|
8
|
+
export interface Praxis extends Omit<Resources, 'application' | 'database'> {
|
|
9
|
+
readonly database: Resources['database'] & {
|
|
10
|
+
count(input: CountInput): Promise<CountResult>;
|
|
11
|
+
};
|
|
8
12
|
readonly application: Resources['application'] & {
|
|
9
13
|
publish(input: PublishInput): Promise<PublishResult>;
|
|
10
14
|
};
|
package/dist/core/client.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { resourceFactories } from "../resources.generated.js";
|
|
2
2
|
import { Transport } from "./transport.js";
|
|
3
3
|
import { publish } from "../helpers/application-publish.js";
|
|
4
|
+
import { count } from "../helpers/database-count.js";
|
|
4
5
|
export class Praxis {
|
|
5
6
|
constructor(options) {
|
|
6
7
|
const transport = new Transport(options);
|
|
7
8
|
for (const [name, create] of Object.entries(resourceFactories)) {
|
|
8
9
|
const resource = create(transport);
|
|
9
10
|
// Assemble before sealing the resource property; never replace a readonly SDK resource.
|
|
11
|
+
if (name === 'database')
|
|
12
|
+
Object.assign(resource, { count: (input) => count(transport, input) });
|
|
10
13
|
if (name === 'application')
|
|
11
14
|
Object.assign(resource, { publish: (input) => publish(this, input) });
|
|
12
15
|
Object.defineProperty(this, name, { value: resource, enumerable: true });
|
package/dist/core/transport.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export declare class Transport {
|
|
|
31
31
|
private validate;
|
|
32
32
|
private scope;
|
|
33
33
|
request<R>(operation: Operation, options?: InternalOptions): Promise<R>;
|
|
34
|
+
/** Internal helper access to response metadata, with the same request policy. */
|
|
35
|
+
requestWithResponse<R>(operation: Operation, options?: InternalOptions): Promise<{
|
|
36
|
+
data: R;
|
|
37
|
+
response: Response;
|
|
38
|
+
}>;
|
|
34
39
|
stream<E extends SSEEvent = SSEEvent>(operation: Operation, options?: InternalOptions): AsyncGenerator<E>;
|
|
35
40
|
}
|
|
36
41
|
export {};
|
package/dist/core/transport.js
CHANGED
|
@@ -92,9 +92,14 @@ export class Transport {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
async request(operation, options = {}) {
|
|
95
|
+
return (await this.requestWithResponse(operation, options)).data;
|
|
96
|
+
}
|
|
97
|
+
/** Internal helper access to response metadata, with the same request policy. */
|
|
98
|
+
async requestWithResponse(operation, options = {}) {
|
|
95
99
|
const scope = this.scope(options, false);
|
|
96
100
|
try {
|
|
97
|
-
|
|
101
|
+
const result = await abortable(operation(scope.options), scope.signal);
|
|
102
|
+
return { data: result.data, response: result.response };
|
|
98
103
|
}
|
|
99
104
|
finally {
|
|
100
105
|
scope.close();
|
|
@@ -38,7 +38,7 @@ export declare const setRunFeedback: <ThrowOnError extends boolean = false>(opti
|
|
|
38
38
|
/**
|
|
39
39
|
* List End Users
|
|
40
40
|
*
|
|
41
|
-
* List users who have sessions or token issuance history on a
|
|
41
|
+
* List users who have sessions or token issuance history on a service agent.
|
|
42
42
|
*
|
|
43
43
|
* Ordered by last_active_at and external_user_id descending. q is a case-sensitive literal prefix, including underscores. limit is 1–100, default 20. Reuse next_page with the same organization, agent, q and limit. Preemptively blocked users without history do not appear. End-user credentials and inaccessible or personal agents return 404.
|
|
44
44
|
*/
|
|
@@ -46,7 +46,7 @@ export declare const listEndUsers: <ThrowOnError extends boolean = false>(option
|
|
|
46
46
|
/**
|
|
47
47
|
* Delete end-user data
|
|
48
48
|
*
|
|
49
|
-
* Delete a host application's end-user data from one
|
|
49
|
+
* Delete a host application's end-user data from one service agent after explicit confirmation.
|
|
50
50
|
*
|
|
51
51
|
* Develop only. Set confirm to the exact external_user_id; missing or mismatched confirmation returns 400. Returns 202 with a pending task id, not completion. Poll the deletion endpoint. Concurrent requests reuse the unfinished task; retry DELETE after failure to resume it. Tokens are revoked and the user is blocked before a seven-day recovery snapshot is verified. Sessions including child sessions, conversation data, grants and feedback are then removed. A pre-existing block remains; a temporary block is removed on success. Attachment metadata is recorded and File attachments are retained. No charge is introduced by this operation. Example: DELETE /agent/v1/agents/agent_example/end_users/customer_123?confirm=customer_123.
|
|
52
52
|
*/
|
|
@@ -118,9 +118,9 @@ export declare const listEmbedTokens: <ThrowOnError extends boolean = false>(opt
|
|
|
118
118
|
/**
|
|
119
119
|
* Create Embed Token
|
|
120
120
|
*
|
|
121
|
-
* Issue a short-lived credential on your backend for an end user of a
|
|
121
|
+
* Issue a short-lived credential on your backend for an end user of a service agent.
|
|
122
122
|
*
|
|
123
|
-
* Requires an active
|
|
123
|
+
* Requires an active service agent in your organization with an embed policy. Pins the requested version or the latest version and snapshots the policy environment, vaults and resources; metadata comes from the request. Blocked users cannot receive tokens. Keep your API key on the backend and pass only the returned token to the frontend. Every call creates a new grant; issuance is not idempotent. Set hosted to true to also receive hosted_url; redirect the user there within 60 seconds. The agent must have an identity_number. The URL fragment contains a single-use exchange credential, not the token. Omit hosted or set false for ordinary token issuance.
|
|
124
124
|
*/
|
|
125
125
|
export declare const createEmbedToken: <ThrowOnError extends boolean = false>(options: Options<CreateEmbedTokenData, ThrowOnError>) => RequestResult<CreateEmbedTokenResponses, CreateEmbedTokenErrors, ThrowOnError>;
|
|
126
126
|
/**
|
|
@@ -851,7 +851,7 @@ export declare const sessionsUpdate: <ThrowOnError extends boolean = false>(opti
|
|
|
851
851
|
/**
|
|
852
852
|
* List agents
|
|
853
853
|
*
|
|
854
|
-
* List the agents of the workspace behind your API key, newest first, in pages of at most 100 (default 20). Use it to find an agent id before creating a session; to read one agent use agents.retrieve, to see its history use agents.versions.list. Archived agents are hidden unless include_archived is true. Filter kind=personal for durable-computer agents or kind=
|
|
854
|
+
* List the agents of the workspace behind your API key, newest first, in pages of at most 100 (default 20). Use it to find an agent id before creating a session; to read one agent use agents.retrieve, to see its history use agents.versions.list. Archived agents are hidden unless include_archived is true. Filter kind=personal for durable-computer agents or kind=service for per-session environments. Pass next_page from the response as page to read the next page; a null next_page means the end.
|
|
855
855
|
*/
|
|
856
856
|
export declare const agentsList: <ThrowOnError extends boolean = false>(options?: Options<AgentsListData, ThrowOnError>) => RequestResult<AgentsListResponses, unknown, ThrowOnError>;
|
|
857
857
|
/**
|
|
@@ -1667,7 +1667,7 @@ export declare const databaseListTables: <ThrowOnError extends boolean = false>(
|
|
|
1667
1667
|
/**
|
|
1668
1668
|
* Create table
|
|
1669
1669
|
*
|
|
1670
|
-
* Creates a table together with its initial fields in one call and returns it (HTTP 201) with generated tbl_ and fld_ ids. name must match ^[a-z_][a-z0-9_]{0,62}$ and be unused in this database (duplicate: 409 UNIQUE_VIOLATION). fields is required and may be an empty array; fields can also be added later with databaseAddField. Limits: 50 tables per database, 64 fields per table, and 16 indexed or unique fields per table; exceeding one returns 400 LIMIT_EXCEEDED. Every row also has a system id column, which is not declared as a field. Insert data afterwards with databaseInsert. Unlike Supabase, define schema with this table API and the field APIs; PostgreSQL DDL and SQL migration files cannot be submitted. Each table supports up to 1,000,000 rows.
|
|
1670
|
+
* Creates a table together with its initial fields in one call and returns it (HTTP 201) with generated tbl_ and fld_ ids. name must match ^[a-z_][a-z0-9_]{0,62}$ and be unused in this database (duplicate: 409 UNIQUE_VIOLATION). fields is required and may be an empty array; fields can also be added later with databaseAddField. Limits: 50 tables per database, 64 fields per table, and 16 indexed or unique fields per table; exceeding one returns 400 LIMIT_EXCEEDED. Fields default to indexed:false. Set indexed:true explicitly for fields used in filters or ordering. Only indexed:true or unique:true consumes one of the 16 indexed-or-unique field slots; a field with both consumes one slot. Unique fields still consume a slot even with indexed:false. Existing fields are unchanged. Minimal field example: {"name":"notes","type":"string","indexed":false}. Every row also has a system id column, which is not declared as a field. Insert data afterwards with databaseInsert. Unlike Supabase, define schema with this table API and the field APIs; PostgreSQL DDL and SQL migration files cannot be submitted. Each table supports up to 1,000,000 rows.
|
|
1671
1671
|
*/
|
|
1672
1672
|
export declare const databaseCreateTable: <ThrowOnError extends boolean = false>(options: Options<DatabaseCreateTableData, ThrowOnError>) => RequestResult<DatabaseCreateTableResponses, DatabaseCreateTableErrors, ThrowOnError>;
|
|
1673
1673
|
/**
|
|
@@ -1691,7 +1691,7 @@ export declare const databaseUpdateTable: <ThrowOnError extends boolean = false>
|
|
|
1691
1691
|
/**
|
|
1692
1692
|
* Add field
|
|
1693
1693
|
*
|
|
1694
|
-
* Adds one field to an existing table and returns the updated table (HTTP 201). Required inputs are name (lowercase letters, digits and underscores; id and names starting with _ are reserved) and type (string, integer, number, boolean, datetime, json or link); json needs options.schema and link needs options.linked_table_id and options.multiple. Adding a required field to a table that already has rows needs a default, otherwise the call fails with 400 VALIDATION_FAILED; a default is written into every existing row.
|
|
1694
|
+
* Adds one field to an existing table and returns the updated table (HTTP 201). Required inputs are name (lowercase letters, digits and underscores; id and names starting with _ are reserved) and type (string, integer, number, boolean, datetime, json or link); json needs options.schema and link needs options.linked_table_id and options.multiple. Adding a required field to a table that already has rows needs a default, otherwise the call fails with 400 VALIDATION_FAILED; a default is written into every existing row. Fields default to indexed:false. Set indexed:true explicitly for fields used in filters or ordering. Only indexed:true or unique:true consumes one of the 16 indexed-or-unique field slots; a field with both consumes one slot. Unique fields still consume a slot even with indexed:false. Existing fields are unchanged. Minimal field example: {"name":"notes","type":"string","indexed":false}. JSON and link fields cannot be indexed. Limits: 64 fields and 16 indexed or unique fields per table (400 LIMIT_EXCEEDED). Unlike Supabase, schema evolution uses field definitions rather than ALTER TABLE statements or SQL migrations.
|
|
1695
1695
|
*/
|
|
1696
1696
|
export declare const databaseAddField: <ThrowOnError extends boolean = false>(options: Options<DatabaseAddFieldData, ThrowOnError>) => RequestResult<DatabaseAddFieldResponses, DatabaseAddFieldErrors, ThrowOnError>;
|
|
1697
1697
|
/**
|
|
@@ -1721,13 +1721,13 @@ export declare const databaseDelete: <ThrowOnError extends boolean = false>(opti
|
|
|
1721
1721
|
/**
|
|
1722
1722
|
* Select rows
|
|
1723
1723
|
*
|
|
1724
|
-
* Read matching rows with filters, selected columns and ordering. Returns at most 1000 rows per request, including when limit is omitted. Content-Range reports the actual returned interval and the total when count is requested. PATCH and DELETE are not subject to this read cap. Unlike Supabase, casts, aggregates, spread and join modifiers are unsupported. Each table supports up to 1,000,000 rows. Query budget: 8,000 ms with a shared 3,000,000-row safety ceiling. Create indexes on filtered or sorted fields, or narrow the request when it exceeds its budget. Synchronous SQLite aggregates use candidate-row throughput estimates before execution; deployed Workers freeze clocks during synchronous CPU work, so the timer is not a guaranteed server-side interrupt. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode. Error table: QUERY_CANCELED / PostgREST 57014 is HTTP 500, retryable=false: Query timed out: index filtered or sorted fields, or narrow the range. DATABASE_INVALID_STATE is HTTP 409 for operations on a deleting database. Cleared or nonexistent databases return DATABASE_NOT_FOUND / HTTP 404. The count is an HTTP Content-Range response header, not a JSON property.
|
|
1724
|
+
* Read matching rows with filters, selected columns and ordering. Returns at most 1000 rows per request, including when limit is omitted. Content-Range reports the actual returned interval and the total when count is requested. PATCH and DELETE are not subject to this read cap. Unlike Supabase, casts, aggregates, spread and join modifiers are unsupported. Each table supports up to 1,000,000 rows. Query budget: 8,000 ms with a shared 3,000,000-row safety ceiling. Create indexes on filtered or sorted fields, or narrow the request when it exceeds its budget. Synchronous SQLite aggregates use candidate-row throughput estimates before execution; deployed Workers freeze clocks during synchronous CPU work, so the timer is not a guaranteed server-side interrupt. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode. Error table: QUERY_CANCELED / PostgREST 57014 is HTTP 500, retryable=false: Query timed out: index filtered or sorted fields, or narrow the range. DATABASE_INVALID_STATE is HTTP 409 for operations on a deleting database. Cleared or nonexistent databases return DATABASE_NOT_FOUND / HTTP 404. The count is an HTTP Content-Range response header, not a JSON property. Use praxis.database.count in the SDK or codemode to return { count: number | null }; a page length is not a total unless you know all matches fit in that page.
|
|
1725
1725
|
*/
|
|
1726
1726
|
export declare const databaseSelect: <ThrowOnError extends boolean = false>(options: Options<DatabaseSelectData, ThrowOnError>) => RequestResult<DatabaseSelectResponses, DatabaseSelectErrors, ThrowOnError>;
|
|
1727
1727
|
/**
|
|
1728
1728
|
* Count rows
|
|
1729
1729
|
*
|
|
1730
|
-
* Inspect the HTTP row count and range without retrieving row data; send Prefer: count=exact for a filtered count. Returns no body and does not fetch or serialize row data. A known count determines the interval using limit/offset or Range with a default and maximum page size of 1000. Without a count preference, or when the selected count mode cannot supply a total, Content-Range is **. Singular Accept still validates page cardinality. Unlike Supabase, planned and estimated counts do not use PostgreSQL planner estimates. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode.
|
|
1730
|
+
* Inspect the HTTP row count and range without retrieving row data; send Prefer: count=exact for a filtered count. Returns no body and does not fetch or serialize row data. A known count determines the interval using limit/offset or Range with a default and maximum page size of 1000. Without a count preference, or when the selected count mode cannot supply a total, Content-Range is **. Singular Accept still validates page cardinality. Unlike Supabase, planned and estimated counts do not use PostgreSQL planner estimates. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode. Use praxis.database.count in the SDK or codemode to return { count: number | null } from this header without retrieving rows.
|
|
1731
1731
|
*/
|
|
1732
1732
|
export declare const databaseHead: <ThrowOnError extends boolean = false>(options: Options<DatabaseHeadData, ThrowOnError>) => RequestResult<DatabaseHeadResponses, DatabaseHeadErrors, ThrowOnError>;
|
|
1733
1733
|
/**
|
|
@@ -1741,7 +1741,7 @@ export declare const databaseUpdate: <ThrowOnError extends boolean = false>(opti
|
|
|
1741
1741
|
*
|
|
1742
1742
|
* Insert rows into an existing table after defining its fields; at most 500 rows per request. Each request is atomic: any failure rolls back the entire batch. There are no transactions across requests.
|
|
1743
1743
|
* Rows are filled to the union of their keys with null; send Prefer: missing=default to use field defaults for missing keys.
|
|
1744
|
-
* The default is return=minimal: success returns HTTP 201 with an empty body. Send Prefer: return=representation to return the inserted rows. Unlike Supabase, upsert conflicts can target only id or one unique field, not a composite key. Each table supports up to 1,000,000 rows.
|
|
1744
|
+
* The default is return=minimal: success returns HTTP 201 with an empty body. Send Prefer: return=representation to return the inserted rows. With resolution=merge-duplicates, a conflicting row keeps columns omitted from the request; supplied values replace the whole field value (including JSON objects), and explicit null clears a nullable field. With resolution=ignore-duplicates, a conflicting row is left unchanged. Without a conflict, both modes insert a new row using field defaults for omitted fields. In a batch, a key present in another row is filled with null when omitted in this row unless missing=default is set; that null can overwrite a value during merge. With missing=default, omitted keys stay omitted for conflict merges (existing values are preserved); new rows use defaults, or null when no default exists. Explicit null never invokes a default. Unlike Supabase, upsert conflicts can target only id or one unique field, not a composite key. Each table supports up to 1,000,000 rows.
|
|
1745
1745
|
*/
|
|
1746
1746
|
export declare const databaseInsert: <ThrowOnError extends boolean = false>(options: Options<DatabaseInsertData, ThrowOnError>) => RequestResult<DatabaseInsertResponses, DatabaseInsertErrors, ThrowOnError>;
|
|
1747
1747
|
/**
|
|
@@ -66,7 +66,7 @@ export const setRunFeedback = (options) => (options.client ?? client).post({
|
|
|
66
66
|
/**
|
|
67
67
|
* List End Users
|
|
68
68
|
*
|
|
69
|
-
* List users who have sessions or token issuance history on a
|
|
69
|
+
* List users who have sessions or token issuance history on a service agent.
|
|
70
70
|
*
|
|
71
71
|
* Ordered by last_active_at and external_user_id descending. q is a case-sensitive literal prefix, including underscores. limit is 1–100, default 20. Reuse next_page with the same organization, agent, q and limit. Preemptively blocked users without history do not appear. End-user credentials and inaccessible or personal agents return 404.
|
|
72
72
|
*/
|
|
@@ -86,7 +86,7 @@ export const listEndUsers = (options) => (options.client ?? client).get({
|
|
|
86
86
|
/**
|
|
87
87
|
* Delete end-user data
|
|
88
88
|
*
|
|
89
|
-
* Delete a host application's end-user data from one
|
|
89
|
+
* Delete a host application's end-user data from one service agent after explicit confirmation.
|
|
90
90
|
*
|
|
91
91
|
* Develop only. Set confirm to the exact external_user_id; missing or mismatched confirmation returns 400. Returns 202 with a pending task id, not completion. Poll the deletion endpoint. Concurrent requests reuse the unfinished task; retry DELETE after failure to resume it. Tokens are revoked and the user is blocked before a seven-day recovery snapshot is verified. Sessions including child sessions, conversation data, grants and feedback are then removed. A pre-existing block remains; a temporary block is removed on success. Attachment metadata is recorded and File attachments are retained. No charge is introduced by this operation. Example: DELETE /agent/v1/agents/agent_example/end_users/customer_123?confirm=customer_123.
|
|
92
92
|
*/
|
|
@@ -256,9 +256,9 @@ export const listEmbedTokens = (options) => (options?.client ?? client).get({
|
|
|
256
256
|
/**
|
|
257
257
|
* Create Embed Token
|
|
258
258
|
*
|
|
259
|
-
* Issue a short-lived credential on your backend for an end user of a
|
|
259
|
+
* Issue a short-lived credential on your backend for an end user of a service agent.
|
|
260
260
|
*
|
|
261
|
-
* Requires an active
|
|
261
|
+
* Requires an active service agent in your organization with an embed policy. Pins the requested version or the latest version and snapshots the policy environment, vaults and resources; metadata comes from the request. Blocked users cannot receive tokens. Keep your API key on the backend and pass only the returned token to the frontend. Every call creates a new grant; issuance is not idempotent. Set hosted to true to also receive hosted_url; redirect the user there within 60 seconds. The agent must have an identity_number. The URL fragment contains a single-use exchange credential, not the token. Omit hosted or set false for ordinary token issuance.
|
|
262
262
|
*/
|
|
263
263
|
export const createEmbedToken = (options) => (options.client ?? client).post({
|
|
264
264
|
security: [{
|
|
@@ -2374,7 +2374,7 @@ export const sessionsUpdate = (options) => (options.client ?? client).post({
|
|
|
2374
2374
|
/**
|
|
2375
2375
|
* List agents
|
|
2376
2376
|
*
|
|
2377
|
-
* List the agents of the workspace behind your API key, newest first, in pages of at most 100 (default 20). Use it to find an agent id before creating a session; to read one agent use agents.retrieve, to see its history use agents.versions.list. Archived agents are hidden unless include_archived is true. Filter kind=personal for durable-computer agents or kind=
|
|
2377
|
+
* List the agents of the workspace behind your API key, newest first, in pages of at most 100 (default 20). Use it to find an agent id before creating a session; to read one agent use agents.retrieve, to see its history use agents.versions.list. Archived agents are hidden unless include_archived is true. Filter kind=personal for durable-computer agents or kind=service for per-session environments. Pass next_page from the response as page to read the next page; a null next_page means the end.
|
|
2378
2378
|
*/
|
|
2379
2379
|
export const agentsList = (options) => (options?.client ?? client).get({
|
|
2380
2380
|
security: [{
|
|
@@ -4908,7 +4908,7 @@ export const databaseListTables = (options) => (options.client ?? client).get({
|
|
|
4908
4908
|
/**
|
|
4909
4909
|
* Create table
|
|
4910
4910
|
*
|
|
4911
|
-
* Creates a table together with its initial fields in one call and returns it (HTTP 201) with generated tbl_ and fld_ ids. name must match ^[a-z_][a-z0-9_]{0,62}$ and be unused in this database (duplicate: 409 UNIQUE_VIOLATION). fields is required and may be an empty array; fields can also be added later with databaseAddField. Limits: 50 tables per database, 64 fields per table, and 16 indexed or unique fields per table; exceeding one returns 400 LIMIT_EXCEEDED. Every row also has a system id column, which is not declared as a field. Insert data afterwards with databaseInsert. Unlike Supabase, define schema with this table API and the field APIs; PostgreSQL DDL and SQL migration files cannot be submitted. Each table supports up to 1,000,000 rows.
|
|
4911
|
+
* Creates a table together with its initial fields in one call and returns it (HTTP 201) with generated tbl_ and fld_ ids. name must match ^[a-z_][a-z0-9_]{0,62}$ and be unused in this database (duplicate: 409 UNIQUE_VIOLATION). fields is required and may be an empty array; fields can also be added later with databaseAddField. Limits: 50 tables per database, 64 fields per table, and 16 indexed or unique fields per table; exceeding one returns 400 LIMIT_EXCEEDED. Fields default to indexed:false. Set indexed:true explicitly for fields used in filters or ordering. Only indexed:true or unique:true consumes one of the 16 indexed-or-unique field slots; a field with both consumes one slot. Unique fields still consume a slot even with indexed:false. Existing fields are unchanged. Minimal field example: {"name":"notes","type":"string","indexed":false}. Every row also has a system id column, which is not declared as a field. Insert data afterwards with databaseInsert. Unlike Supabase, define schema with this table API and the field APIs; PostgreSQL DDL and SQL migration files cannot be submitted. Each table supports up to 1,000,000 rows.
|
|
4912
4912
|
*/
|
|
4913
4913
|
export const databaseCreateTable = (options) => (options.client ?? client).post({
|
|
4914
4914
|
security: [{
|
|
@@ -4972,7 +4972,7 @@ export const databaseUpdateTable = (options) => (options.client ?? client).patch
|
|
|
4972
4972
|
/**
|
|
4973
4973
|
* Add field
|
|
4974
4974
|
*
|
|
4975
|
-
* Adds one field to an existing table and returns the updated table (HTTP 201). Required inputs are name (lowercase letters, digits and underscores; id and names starting with _ are reserved) and type (string, integer, number, boolean, datetime, json or link); json needs options.schema and link needs options.linked_table_id and options.multiple. Adding a required field to a table that already has rows needs a default, otherwise the call fails with 400 VALIDATION_FAILED; a default is written into every existing row.
|
|
4975
|
+
* Adds one field to an existing table and returns the updated table (HTTP 201). Required inputs are name (lowercase letters, digits and underscores; id and names starting with _ are reserved) and type (string, integer, number, boolean, datetime, json or link); json needs options.schema and link needs options.linked_table_id and options.multiple. Adding a required field to a table that already has rows needs a default, otherwise the call fails with 400 VALIDATION_FAILED; a default is written into every existing row. Fields default to indexed:false. Set indexed:true explicitly for fields used in filters or ordering. Only indexed:true or unique:true consumes one of the 16 indexed-or-unique field slots; a field with both consumes one slot. Unique fields still consume a slot even with indexed:false. Existing fields are unchanged. Minimal field example: {"name":"notes","type":"string","indexed":false}. JSON and link fields cannot be indexed. Limits: 64 fields and 16 indexed or unique fields per table (400 LIMIT_EXCEEDED). Unlike Supabase, schema evolution uses field definitions rather than ALTER TABLE statements or SQL migrations.
|
|
4976
4976
|
*/
|
|
4977
4977
|
export const databaseAddField = (options) => (options.client ?? client).post({
|
|
4978
4978
|
security: [{
|
|
@@ -5050,7 +5050,7 @@ export const databaseDelete = (options) => (options.client ?? client).delete({
|
|
|
5050
5050
|
/**
|
|
5051
5051
|
* Select rows
|
|
5052
5052
|
*
|
|
5053
|
-
* Read matching rows with filters, selected columns and ordering. Returns at most 1000 rows per request, including when limit is omitted. Content-Range reports the actual returned interval and the total when count is requested. PATCH and DELETE are not subject to this read cap. Unlike Supabase, casts, aggregates, spread and join modifiers are unsupported. Each table supports up to 1,000,000 rows. Query budget: 8,000 ms with a shared 3,000,000-row safety ceiling. Create indexes on filtered or sorted fields, or narrow the request when it exceeds its budget. Synchronous SQLite aggregates use candidate-row throughput estimates before execution; deployed Workers freeze clocks during synchronous CPU work, so the timer is not a guaranteed server-side interrupt. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode. Error table: QUERY_CANCELED / PostgREST 57014 is HTTP 500, retryable=false: Query timed out: index filtered or sorted fields, or narrow the range. DATABASE_INVALID_STATE is HTTP 409 for operations on a deleting database. Cleared or nonexistent databases return DATABASE_NOT_FOUND / HTTP 404. The count is an HTTP Content-Range response header, not a JSON property.
|
|
5053
|
+
* Read matching rows with filters, selected columns and ordering. Returns at most 1000 rows per request, including when limit is omitted. Content-Range reports the actual returned interval and the total when count is requested. PATCH and DELETE are not subject to this read cap. Unlike Supabase, casts, aggregates, spread and join modifiers are unsupported. Each table supports up to 1,000,000 rows. Query budget: 8,000 ms with a shared 3,000,000-row safety ceiling. Create indexes on filtered or sorted fields, or narrow the request when it exceeds its budget. Synchronous SQLite aggregates use candidate-row throughput estimates before execution; deployed Workers freeze clocks during synchronous CPU work, so the timer is not a guaranteed server-side interrupt. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode. Error table: QUERY_CANCELED / PostgREST 57014 is HTTP 500, retryable=false: Query timed out: index filtered or sorted fields, or narrow the range. DATABASE_INVALID_STATE is HTTP 409 for operations on a deleting database. Cleared or nonexistent databases return DATABASE_NOT_FOUND / HTTP 404. The count is an HTTP Content-Range response header, not a JSON property. Use praxis.database.count in the SDK or codemode to return { count: number | null }; a page length is not a total unless you know all matches fit in that page.
|
|
5054
5054
|
*/
|
|
5055
5055
|
export const databaseSelect = (options) => (options.client ?? client).get({
|
|
5056
5056
|
security: [{
|
|
@@ -5064,7 +5064,7 @@ export const databaseSelect = (options) => (options.client ?? client).get({
|
|
|
5064
5064
|
/**
|
|
5065
5065
|
* Count rows
|
|
5066
5066
|
*
|
|
5067
|
-
* Inspect the HTTP row count and range without retrieving row data; send Prefer: count=exact for a filtered count. Returns no body and does not fetch or serialize row data. A known count determines the interval using limit/offset or Range with a default and maximum page size of 1000. Without a count preference, or when the selected count mode cannot supply a total, Content-Range is **. Singular Accept still validates page cardinality. Unlike Supabase, planned and estimated counts do not use PostgreSQL planner estimates. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode.
|
|
5067
|
+
* Inspect the HTTP row count and range without retrieving row data; send Prefer: count=exact for a filtered count. Returns no body and does not fetch or serialize row data. A known count determines the interval using limit/offset or Range with a default and maximum page size of 1000. Without a count preference, or when the selected count mode cannot supply a total, Content-Range is **. Singular Accept still validates page cardinality. Unlike Supabase, planned and estimated counts do not use PostgreSQL planner estimates. Count preferences: without filters, exact, planned and estimated all use SQLite's exact b-tree count. With filters, exact counts within budget; planned skips counting and reports an unknown total (Content-Range: 0-24*); estimated attempts exact counting only when the preflight budget allows it, otherwise reports an unknown total. Preference-Applied echoes the requested count mode. Use praxis.database.count in the SDK or codemode to return { count: number | null } from this header without retrieving rows.
|
|
5068
5068
|
*/
|
|
5069
5069
|
export const databaseHead = (options) => (options.client ?? client).head({
|
|
5070
5070
|
security: [{
|
|
@@ -5098,7 +5098,7 @@ export const databaseUpdate = (options) => (options.client ?? client).patch({
|
|
|
5098
5098
|
*
|
|
5099
5099
|
* Insert rows into an existing table after defining its fields; at most 500 rows per request. Each request is atomic: any failure rolls back the entire batch. There are no transactions across requests.
|
|
5100
5100
|
* Rows are filled to the union of their keys with null; send Prefer: missing=default to use field defaults for missing keys.
|
|
5101
|
-
* The default is return=minimal: success returns HTTP 201 with an empty body. Send Prefer: return=representation to return the inserted rows. Unlike Supabase, upsert conflicts can target only id or one unique field, not a composite key. Each table supports up to 1,000,000 rows.
|
|
5101
|
+
* The default is return=minimal: success returns HTTP 201 with an empty body. Send Prefer: return=representation to return the inserted rows. With resolution=merge-duplicates, a conflicting row keeps columns omitted from the request; supplied values replace the whole field value (including JSON objects), and explicit null clears a nullable field. With resolution=ignore-duplicates, a conflicting row is left unchanged. Without a conflict, both modes insert a new row using field defaults for omitted fields. In a batch, a key present in another row is filled with null when omitted in this row unless missing=default is set; that null can overwrite a value during merge. With missing=default, omitted keys stay omitted for conflict merges (existing values are preserved); new rows use defaults, or null when no default exists. Explicit null never invokes a default. Unlike Supabase, upsert conflicts can target only id or one unique field, not a composite key. Each table supports up to 1,000,000 rows.
|
|
5102
5102
|
*/
|
|
5103
5103
|
export const databaseInsert = (options) => (options.client ?? client).post({
|
|
5104
5104
|
security: [{
|