@valtrix/sdk 0.3.0 → 0.4.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/dist/client.d.ts +3 -2
- package/dist/client.js +3 -3
- package/dist/codegen.js +4 -2
- package/dist/protocol.d.ts +1 -1
- package/package.json +45 -51
- package/src/index.ts +0 -56
package/dist/client.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export type ClientShape = {
|
|
|
168
168
|
tables: Record<string, object>;
|
|
169
169
|
records: Record<string, object>;
|
|
170
170
|
};
|
|
171
|
-
export type
|
|
171
|
+
export type RecordLookupResult = {
|
|
172
172
|
record: {
|
|
173
173
|
id: string;
|
|
174
174
|
entityType: string;
|
|
@@ -187,8 +187,9 @@ export type ValtrixClient<S extends ClientShape> = {
|
|
|
187
187
|
} & {
|
|
188
188
|
records: {
|
|
189
189
|
[K in keyof S['records']]: RecordHandle<S['records'][K]>;
|
|
190
|
+
} & {
|
|
191
|
+
get: (recordId: string) => Promise<RecordLookupResult>;
|
|
190
192
|
};
|
|
191
|
-
recordById: (recordId: string) => Promise<RecordByIdResult>;
|
|
192
193
|
connect: ConnectApi;
|
|
193
194
|
orgs: OrgsApi;
|
|
194
195
|
schema: () => Promise<ApiSchema>;
|
package/dist/client.js
CHANGED
|
@@ -296,9 +296,8 @@ export function createClient(config) {
|
|
|
296
296
|
for (const entityType of config.records) {
|
|
297
297
|
records[entityType] = new RecordHandle(http, entityType);
|
|
298
298
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const response = await http.request('GET', `/v1/records/by-id/${encodeURIComponent(recordId)}`);
|
|
299
|
+
records.get = async (recordId) => {
|
|
300
|
+
const response = await http.request('GET', `/v1/records/${encodeURIComponent(recordId)}`);
|
|
302
301
|
return {
|
|
303
302
|
record: {
|
|
304
303
|
id: response.record.id,
|
|
@@ -311,6 +310,7 @@ export function createClient(config) {
|
|
|
311
310
|
tables: response.tables,
|
|
312
311
|
};
|
|
313
312
|
};
|
|
313
|
+
client.records = records;
|
|
314
314
|
client.connect = new ConnectApi(http);
|
|
315
315
|
client.orgs = new OrgsApi(http);
|
|
316
316
|
client.schema = () => http.request('GET', '/v1/schema');
|
package/dist/codegen.js
CHANGED
|
@@ -30,6 +30,8 @@ function columnDoc(column, indent) {
|
|
|
30
30
|
const extra = [];
|
|
31
31
|
if (column.type === 'date')
|
|
32
32
|
extra.push('ISO 8601 date string.');
|
|
33
|
+
if (column.type === 'reference')
|
|
34
|
+
extra.push('Valtrix record ID of the referenced record.');
|
|
33
35
|
if (column.writable)
|
|
34
36
|
extra.push('Writable through valtrix.records.');
|
|
35
37
|
return docComment(column.description, extra, indent);
|
|
@@ -54,11 +56,11 @@ export function emitClientSource(schema, options = {}) {
|
|
|
54
56
|
tables.forEach((table, index) => {
|
|
55
57
|
const { interfaceName } = tableProperties[index];
|
|
56
58
|
const identityNote = table.row_identity === 'record'
|
|
57
|
-
? ' Rows keep their source record ids; _record_id resolves via
|
|
59
|
+
? ' Rows keep their source record ids; _record_id (rec_ prefix) resolves via records.get().'
|
|
58
60
|
: table.row_identity === 'synthetic'
|
|
59
61
|
? ' Rows are derived aggregates; _record_id is synthetic (syn_ prefix) and does not resolve to a record.'
|
|
60
62
|
: table.row_identity === 'mixed'
|
|
61
|
-
? ' Rows mix
|
|
63
|
+
? ' Rows mix record (rec_ prefix) and synthetic (syn_ prefix) ids; only record ids resolve via records.get().'
|
|
62
64
|
: '';
|
|
63
65
|
const header = docComment(`Table "${table.name}" (${table.entity_type}), schema ${table.schema_version ?? 'unpublished'}.${identityNote}`, [], '');
|
|
64
66
|
parts.push(`${header}export interface ${interfaceName} {`);
|
package/dist/protocol.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,53 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"valtrix": "./bin/valtrix.mjs"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"bin",
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"keywords": [
|
|
20
|
-
"valtrix",
|
|
21
|
-
"sdk",
|
|
22
|
-
"typed-client",
|
|
23
|
-
"codegen",
|
|
24
|
-
"data-api"
|
|
25
|
-
],
|
|
26
|
-
"engines": {
|
|
27
|
-
"node": ">=18.17"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public",
|
|
31
|
-
"main": "./dist/index.js",
|
|
32
|
-
"types": "./dist/index.d.ts",
|
|
33
|
-
"exports": {
|
|
34
|
-
".": {
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
36
|
-
"import": "./dist/index.js"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsc -p tsconfig.build.json",
|
|
42
|
-
"prepublishOnly": "pnpm build && pnpm test:run",
|
|
43
|
-
"typecheck": "tsc --noEmit",
|
|
44
|
-
"test": "vitest",
|
|
45
|
-
"test:run": "vitest run"
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@types/node": "^25.0.8",
|
|
49
|
-
"@valtrix/tsconfig": "workspace:*",
|
|
50
|
-
"typescript": "^5.9.3",
|
|
51
|
-
"vitest": "^4.0.17"
|
|
2
|
+
"name": "@valtrix/sdk",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Typed client and codegen CLI for the Valtrix Tables API. Run valtrix generate to get a client typed against your published tables.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
52
13
|
}
|
|
53
|
-
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"valtrix": "./bin/valtrix.mjs"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin",
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"valtrix",
|
|
24
|
+
"sdk",
|
|
25
|
+
"typed-client",
|
|
26
|
+
"codegen",
|
|
27
|
+
"data-api"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.17"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^25.0.8",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"vitest": "^4.0.17",
|
|
39
|
+
"@valtrix/tsconfig": "1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.build.json",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"test": "vitest",
|
|
45
|
+
"test:run": "vitest run"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/index.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
ConnectApi,
|
|
3
|
-
createClient,
|
|
4
|
-
OrgsApi,
|
|
5
|
-
RecordHandle,
|
|
6
|
-
TableHandle,
|
|
7
|
-
} from './client.js'
|
|
8
|
-
export type {
|
|
9
|
-
ClientShape,
|
|
10
|
-
CreateClientConfig,
|
|
11
|
-
FindManyQuery,
|
|
12
|
-
MetaFields,
|
|
13
|
-
OrderBy,
|
|
14
|
-
Org,
|
|
15
|
-
OrgsPage,
|
|
16
|
-
OrgsQuery,
|
|
17
|
-
OrgStatus,
|
|
18
|
-
RecordIdFilter,
|
|
19
|
-
RowsPage,
|
|
20
|
-
TableChange,
|
|
21
|
-
TableWriteOutcome,
|
|
22
|
-
UpsertResult,
|
|
23
|
-
ValtrixClient,
|
|
24
|
-
Where,
|
|
25
|
-
WhereOperators,
|
|
26
|
-
WhereValue,
|
|
27
|
-
} from './client.js'
|
|
28
|
-
export {
|
|
29
|
-
errorFromResponse,
|
|
30
|
-
ValtrixAuthError,
|
|
31
|
-
ValtrixCursorExpiredError,
|
|
32
|
-
ValtrixError,
|
|
33
|
-
ValtrixRateLimitError,
|
|
34
|
-
} from './errors.js'
|
|
35
|
-
export type { FieldIssue } from './errors.js'
|
|
36
|
-
export { camelCase, emitClientSource, pascalCase } from './codegen.js'
|
|
37
|
-
export type { GeneratedClient } from './codegen.js'
|
|
38
|
-
export { runCli } from './cli.js'
|
|
39
|
-
export type {
|
|
40
|
-
ApiChange,
|
|
41
|
-
ApiChangesResponse,
|
|
42
|
-
ApiColumn,
|
|
43
|
-
ApiConnectSessionResponse,
|
|
44
|
-
ApiDeleteResponse,
|
|
45
|
-
ApiOrg,
|
|
46
|
-
ApiOrgConnection,
|
|
47
|
-
ApiOrgsResponse,
|
|
48
|
-
ApiRecord,
|
|
49
|
-
ApiRecordResponse,
|
|
50
|
-
ApiRecordType,
|
|
51
|
-
ApiRowsResponse,
|
|
52
|
-
ApiSchema,
|
|
53
|
-
ApiTable,
|
|
54
|
-
ApiTableOutcome,
|
|
55
|
-
ApiUpsertResponse,
|
|
56
|
-
} from './protocol.js'
|