@geniee-inc/sfa-kit 1.11.0 → 1.13.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/GUIDE.md +244 -1
- package/package.json +1 -1
- package/src/index.d.ts +10 -2
- package/src/index.js +6 -1
- package/src/lib/auth/StandalonePreviewContext.d.ts +1 -0
- package/src/lib/auth/embed-protocol.d.ts +1 -0
- package/src/lib/auth/embed-protocol.js +2 -1
- package/src/lib/components/ErrorSnackbar.d.ts +53 -0
- package/src/lib/components/ErrorSnackbar.js +112 -0
- package/src/lib/hooks/splitBulkRows.d.ts +30 -0
- package/src/lib/hooks/splitBulkRows.js +42 -0
- package/src/lib/hooks/useBulkCreateRecords.d.ts +56 -0
- package/src/lib/hooks/useBulkCreateRecords.js +41 -0
- package/src/lib/hooks/useBulkDeleteRecords.d.ts +50 -0
- package/src/lib/hooks/useBulkDeleteRecords.js +36 -0
- package/src/lib/hooks/useBulkUpdateRecords.d.ts +55 -0
- package/src/lib/hooks/useBulkUpdateRecords.js +37 -0
- package/src/lib/hooks/useBulkWrite.d.ts +55 -0
- package/src/lib/hooks/useBulkWrite.js +160 -0
- package/src/lib/hooks/useRecordList.js +12 -6
- package/src/lib/provider/SfaClient.d.ts +111 -3
- package/src/lib/provider/SfaClient.js +440 -29
- package/src/lib/provider/SfaProvider.js +24 -17
- package/src/lib/provider/types.d.ts +86 -2
- package/src/lib/version.d.ts +1 -1
- package/src/lib/version.js +1 -1
|
@@ -50,6 +50,15 @@ export interface SfaListResponse {
|
|
|
50
50
|
/** Cursor for fetching the previous page (keystone cursor-based pagination). */
|
|
51
51
|
readonly prevCursor?: string | null;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* @description The shape of the client SfaProvider hands out — not an
|
|
55
|
+
* extension point.
|
|
56
|
+
*
|
|
57
|
+
* NOTE: methods are added here as the API surface grows, so this interface is
|
|
58
|
+
* not treated as a breaking change when it gains one. Consumers take the
|
|
59
|
+
* client from `useSfaClient()`; a test that needs a stand-in mocks that hook
|
|
60
|
+
* rather than implementing this.
|
|
61
|
+
*/
|
|
53
62
|
export interface SfaClientInterface {
|
|
54
63
|
get(collection: string, recordId: string): Promise<SfaRecord>;
|
|
55
64
|
list(collection: string, params?: SfaListParams): Promise<SfaListResponse>;
|
|
@@ -59,12 +68,21 @@ export interface SfaClientInterface {
|
|
|
59
68
|
create(collection: string, fields: Record<string, unknown>, options?: SfaCreateOptions): Promise<SfaRecord>;
|
|
60
69
|
update(collection: string, recordId: string, fields: Record<string, unknown>, version: string): Promise<SfaRecord>;
|
|
61
70
|
delete(collection: string, recordId: string, version: string): Promise<void>;
|
|
71
|
+
bulkCreate(collection: string, rows: readonly Record<string, unknown>[]): Promise<readonly SfaBulkRowResult[]>;
|
|
72
|
+
bulkUpdate(collection: string, rows: readonly SfaBulkUpdateRow[]): Promise<readonly SfaBulkRowResult[]>;
|
|
73
|
+
bulkDelete(collection: string, rows: readonly SfaBulkDeleteRow[]): Promise<readonly SfaBulkRowResult[]>;
|
|
62
74
|
}
|
|
63
75
|
/**
|
|
64
|
-
* @description Options for creating
|
|
65
|
-
*
|
|
76
|
+
* @description Options for creating one record. Its only member is
|
|
77
|
+
* deprecated, so the type itself goes at the next breaking release.
|
|
66
78
|
*/
|
|
67
79
|
export interface SfaCreateOptions {
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Accepted and ignored. Keystone never de-duplicated on
|
|
82
|
+
* `Idempotency-Key`, and SFAJAI-294 drops the header from the contract, so
|
|
83
|
+
* the kit no longer sends it. Kept only because removing it would fail the
|
|
84
|
+
* build of callers that pass it; drop it at the next breaking release.
|
|
85
|
+
*/
|
|
68
86
|
readonly idempotencyKey?: string;
|
|
69
87
|
}
|
|
70
88
|
/**
|
|
@@ -75,6 +93,70 @@ export interface SfaFieldError {
|
|
|
75
93
|
readonly code: string;
|
|
76
94
|
readonly message: string;
|
|
77
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @description How one row of a bulk write ended.
|
|
98
|
+
*
|
|
99
|
+
* `conflict` means the row's `version` no longer matched, `invalid` that it
|
|
100
|
+
* failed validation. `not_attempted` means the call ran out of budget before
|
|
101
|
+
* this row started, so nothing was written and it can be sent again exactly as
|
|
102
|
+
* it was. `indeterminate` means the server cannot say whether the row applied.
|
|
103
|
+
* All are reported per row with HTTP 200 — a bulk call is best-effort and has
|
|
104
|
+
* no all-or-nothing mode.
|
|
105
|
+
*
|
|
106
|
+
* `unknown` is not sent by the API: it is what the kit reads an unrecognised
|
|
107
|
+
* status as, and what a claimed success it cannot make sense of becomes — no
|
|
108
|
+
* record, or no `version` for the next write to lock against. The row keeps
|
|
109
|
+
* its `id`, and reaches the caller in `unresolved`, never in `failed`:
|
|
110
|
+
* retrying a create that already landed writes a second record.
|
|
111
|
+
*/
|
|
112
|
+
export type SfaBulkRowStatus = 'created' | 'updated' | 'deleted' | 'conflict' | 'invalid' | 'not_attempted' | 'indeterminate' | 'unknown';
|
|
113
|
+
/** @description One row of a bulk update: what to change and from which version. */
|
|
114
|
+
export interface SfaBulkUpdateRow {
|
|
115
|
+
readonly id: string;
|
|
116
|
+
/**
|
|
117
|
+
* The version last read for this record. A mismatch makes this row a
|
|
118
|
+
* `conflict` and leaves it unchanged; the rest of the batch still applies.
|
|
119
|
+
*/
|
|
120
|
+
readonly version: string;
|
|
121
|
+
/** Only the keys present are changed. */
|
|
122
|
+
readonly fields: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
/** @description One row of a bulk delete: what to remove and from which version. */
|
|
125
|
+
export interface SfaBulkDeleteRow {
|
|
126
|
+
readonly id: string;
|
|
127
|
+
/** As in an update — a stale version makes this row a `conflict`. */
|
|
128
|
+
readonly version: string;
|
|
129
|
+
}
|
|
130
|
+
/** @description The outcome of one submitted row, positioned by `index`. */
|
|
131
|
+
export interface SfaBulkRowResult {
|
|
132
|
+
/** Zero-based position in the request, for mapping the result back to input. */
|
|
133
|
+
readonly index: number;
|
|
134
|
+
/**
|
|
135
|
+
* The record's identifier. Always present for update and delete; on create
|
|
136
|
+
* only once the row succeeded. Null when the response carried none the
|
|
137
|
+
* caller could use, which makes the row count as not landed.
|
|
138
|
+
*/
|
|
139
|
+
readonly id: string | null;
|
|
140
|
+
readonly status: SfaBulkRowStatus;
|
|
141
|
+
/**
|
|
142
|
+
* On a successful create or update, the resulting record. On a conflict, the
|
|
143
|
+
* server's current state, so the caller can show what it lost to. Otherwise
|
|
144
|
+
* null — including when the response carried a record that could not be
|
|
145
|
+
* read, since an unusable record is nothing to write back or reconcile
|
|
146
|
+
* against.
|
|
147
|
+
*/
|
|
148
|
+
readonly record: SfaRecord | null;
|
|
149
|
+
/** Set on `conflict` and `invalid`: the problem detail for this row. */
|
|
150
|
+
readonly error: SfaBulkRowError | null;
|
|
151
|
+
}
|
|
152
|
+
/** @description Why one row failed, in the same shape single writes report. */
|
|
153
|
+
export interface SfaBulkRowError {
|
|
154
|
+
/** Machine-readable problem code, e.g. `version_mismatch`. */
|
|
155
|
+
readonly code: string;
|
|
156
|
+
readonly message: string;
|
|
157
|
+
/** Per-field errors when the row failed validation. */
|
|
158
|
+
readonly fieldErrors: readonly SfaFieldError[];
|
|
159
|
+
}
|
|
78
160
|
export interface SfaListParams {
|
|
79
161
|
readonly limit?: number;
|
|
80
162
|
readonly offset?: number;
|
|
@@ -83,6 +165,8 @@ export interface SfaListParams {
|
|
|
83
165
|
readonly filter?: Record<string, unknown>;
|
|
84
166
|
/** Opaque cursor for keystone cursor-based pagination. Takes precedence over offset. */
|
|
85
167
|
readonly cursor?: string;
|
|
168
|
+
/** List tab pre-filter. Sent as `list_id` in the keystone query body. */
|
|
169
|
+
readonly listId?: string;
|
|
86
170
|
}
|
|
87
171
|
export type SfaObjectOrigin = 'standard' | 'custom';
|
|
88
172
|
export type SfaRelationshipKind = 'association' | 'master_detail';
|
package/src/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SFA_KIT_VERSION = "1.
|
|
1
|
+
export declare const SFA_KIT_VERSION = "1.13.0";
|
package/src/lib/version.js
CHANGED