@cratestack/refine 0.7.14 → 0.7.17
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/README.md +151 -53
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/filter-operators.d.ts +12 -0
- package/dist/filter-operators.d.ts.map +1 -0
- package/dist/filter-operators.js +60 -0
- package/dist/filter-operators.js.map +1 -0
- package/dist/filters.d.ts +17 -0
- package/dist/filters.d.ts.map +1 -0
- package/dist/filters.js +33 -0
- package/dist/filters.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +210 -0
- package/dist/index.js.map +1 -0
- package/dist/rpc-filters.d.ts +25 -0
- package/dist/rpc-filters.d.ts.map +1 -0
- package/dist/rpc-filters.js +40 -0
- package/dist/rpc-filters.js.map +1 -0
- package/dist/rpc-many.d.ts +16 -0
- package/dist/rpc-many.d.ts.map +1 -0
- package/dist/rpc-many.js +40 -0
- package/dist/rpc-many.js.map +1 -0
- package/dist/rpc-provider.d.ts +30 -0
- package/dist/rpc-provider.d.ts.map +1 -0
- package/dist/rpc-provider.js +159 -0
- package/dist/rpc-provider.js.map +1 -0
- package/dist/rpc-types.d.ts +95 -0
- package/dist/rpc-types.d.ts.map +1 -0
- package/dist/rpc-types.js +2 -0
- package/dist/rpc-types.js.map +1 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +37 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +50 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { toRefineError } from "./errors.js";
|
|
2
|
+
import { toQueryFilters, toSortQuery } from "./filters.js";
|
|
3
|
+
import { createVersionCache, forgetVersion, ifMatchHeaders, rememberVersion } from "./version.js";
|
|
4
|
+
export { isCratestackHttpError, toRefineError } from "./errors.js";
|
|
5
|
+
export { toQueryFilters, toSortQuery } from "./filters.js";
|
|
6
|
+
// RPC transport (`transport rpc` schemas) — additive sibling of the REST
|
|
7
|
+
// exports above. See rpc-provider.ts's doc comment for how it differs.
|
|
8
|
+
export { toRpcQueryFilters, toRpcSortQuery } from "./rpc-filters.js";
|
|
9
|
+
export { createCratestackRpcDataProvider } from "./rpc-provider.js";
|
|
10
|
+
function withRefineId(record, primaryKey) {
|
|
11
|
+
// The cast is honest, not a shortcut: cratestack's `@id` is always a
|
|
12
|
+
// scalar (Int, Cuid, String, …), all of which are `BaseKey` (`string |
|
|
13
|
+
// number`) at the JSON-decoded value level — `unknown` here is a gap
|
|
14
|
+
// in what `Row`'s index signature can express, not genuine uncertainty
|
|
15
|
+
// about the runtime type.
|
|
16
|
+
return { ...record, id: record[primaryKey] };
|
|
17
|
+
}
|
|
18
|
+
function requireResource(resources, resource) {
|
|
19
|
+
const config = resources[resource];
|
|
20
|
+
if (!config) {
|
|
21
|
+
throw new Error(`no cratestack resource configured for "${resource}" — add it to the "resources" map ` +
|
|
22
|
+
"passed to createCratestackDataProvider");
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
26
|
+
/** Builds a refine `DataProvider` over one or more cratestack generated
|
|
27
|
+
* REST model classes (`client.widgets`, `client.ledgers`, …), given a
|
|
28
|
+
* manifest describing each resource's primary-key field, `@@paged`
|
|
29
|
+
* status, and `@version` field.
|
|
30
|
+
*
|
|
31
|
+
* Write that manifest by hand, or generate it: `cratestack
|
|
32
|
+
* generate-typescript --refine` emits a `src/refine.ts` next to the
|
|
33
|
+
* client whose `cratestackRefineResources(client)` returns exactly this
|
|
34
|
+
* {@link ResourceMap}. The provider itself is not generated and has no
|
|
35
|
+
* CLI subcommand — see the package README's "A runtime package with a
|
|
36
|
+
* generated manifest" section for the split.
|
|
37
|
+
*
|
|
38
|
+
* RPC-transport schemas aren't wired here — see the README's "REST
|
|
39
|
+
* only" note. */
|
|
40
|
+
export function createCratestackDataProvider(resources, options = {}) {
|
|
41
|
+
const versionCache = createVersionCache();
|
|
42
|
+
async function getList(params) {
|
|
43
|
+
const config = requireResource(resources, params.resource);
|
|
44
|
+
const usePaging = config.paged && params.pagination?.mode !== "off";
|
|
45
|
+
const currentPage = params.pagination?.currentPage ?? 1;
|
|
46
|
+
const pageSize = params.pagination?.pageSize ?? 10;
|
|
47
|
+
const sort = toSortQuery(params.sorters);
|
|
48
|
+
const query = {
|
|
49
|
+
filters: toQueryFilters(params.filters),
|
|
50
|
+
...(sort ? { sort } : {}),
|
|
51
|
+
...(usePaging ? { limit: pageSize, offset: (currentPage - 1) * pageSize } : {}),
|
|
52
|
+
};
|
|
53
|
+
const result = await config.api.list({ query });
|
|
54
|
+
const items = config.paged ? result.items : result;
|
|
55
|
+
for (const item of items) {
|
|
56
|
+
rememberVersion(versionCache, params.resource, item[config.primaryKey], item, config);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
data: items.map((item) => withRefineId(item, config.primaryKey)),
|
|
60
|
+
// A non-`@@paged` resource has no server-computed total beyond what
|
|
61
|
+
// one page returned — `items.length` here is honest about *that*
|
|
62
|
+
// response, not a claim about the full row count. See the README's
|
|
63
|
+
// "Pagination" section before wiring page controls to one.
|
|
64
|
+
total: config.paged
|
|
65
|
+
? (result.totalCount ?? items.length)
|
|
66
|
+
: items.length,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function getOne(params) {
|
|
70
|
+
const config = requireResource(resources, params.resource);
|
|
71
|
+
try {
|
|
72
|
+
const record = (await config.api.get(params.id));
|
|
73
|
+
rememberVersion(versionCache, params.resource, params.id, record, config);
|
|
74
|
+
return { data: withRefineId(record, config.primaryKey) };
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw toRefineError(error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Optional on `DataProvider` — refine only falls back to it when it's
|
|
81
|
+
// implemented. Because the `in` operator applies to any required
|
|
82
|
+
// field, including the primary key, this is one `list()` call rather
|
|
83
|
+
// than N `getOne` calls.
|
|
84
|
+
async function getMany(params) {
|
|
85
|
+
const config = requireResource(resources, params.resource);
|
|
86
|
+
const query = {
|
|
87
|
+
filters: { [`${config.primaryKey}__in`]: params.ids.map(String).join(",") },
|
|
88
|
+
};
|
|
89
|
+
const result = await config.api.list({ query });
|
|
90
|
+
const items = config.paged ? result.items : result;
|
|
91
|
+
for (const item of items) {
|
|
92
|
+
rememberVersion(versionCache, params.resource, item[config.primaryKey], item, config);
|
|
93
|
+
}
|
|
94
|
+
return { data: items.map((item) => withRefineId(item, config.primaryKey)) };
|
|
95
|
+
}
|
|
96
|
+
async function create(params) {
|
|
97
|
+
const config = requireResource(resources, params.resource);
|
|
98
|
+
if (!config.api.create) {
|
|
99
|
+
throw new Error(`"${params.resource}" has no generated create route — its model declares no ` +
|
|
100
|
+
'@@allow("create", ...) policy');
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const record = (await config.api.create(params.variables));
|
|
104
|
+
rememberVersion(versionCache, params.resource, record[config.primaryKey], record, config);
|
|
105
|
+
return { data: withRefineId(record, config.primaryKey) };
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw toRefineError(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function update(params) {
|
|
112
|
+
const config = requireResource(resources, params.resource);
|
|
113
|
+
const headers = ifMatchHeaders(versionCache, params.resource, params.id, config, params.meta?.ifMatch);
|
|
114
|
+
try {
|
|
115
|
+
const record = (await config.api.update(params.id, params.variables, { headers }));
|
|
116
|
+
rememberVersion(versionCache, params.resource, params.id, record, config);
|
|
117
|
+
return { data: withRefineId(record, config.primaryKey) };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw toRefineError(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async function deleteOne(params) {
|
|
124
|
+
const config = requireResource(resources, params.resource);
|
|
125
|
+
const headers = ifMatchHeaders(versionCache, params.resource, params.id, config, params.meta?.ifMatch);
|
|
126
|
+
try {
|
|
127
|
+
await config.api.delete(params.id, { headers });
|
|
128
|
+
return { data: { id: params.id } };
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
throw toRefineError(error);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
forgetVersion(versionCache, params.resource, params.id);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// createMany/updateMany/deleteMany: IMPLEMENTED, not declined — but as
|
|
138
|
+
// N sequential single-record round trips via Promise.all, each going
|
|
139
|
+
// through the same create/update/deleteOne above (so If-Match/version-
|
|
140
|
+
// cache/error-mapping behavior stays identical to the single-record
|
|
141
|
+
// path). This is a real, working implementation, just not an atomic
|
|
142
|
+
// or batched one: the generated REST client exposes no `updateMany`/
|
|
143
|
+
// `deleteMany` wrapper over the server's real `update_many`/
|
|
144
|
+
// `delete_many`, and REST-transport schemas have no `/rpc/batch`
|
|
145
|
+
// endpoint (that's RPC-transport only) — see the package README.
|
|
146
|
+
async function createMany(params) {
|
|
147
|
+
const meta = params.meta;
|
|
148
|
+
const records = await Promise.all(params.variables.map((variables) => create(meta
|
|
149
|
+
? { resource: params.resource, variables, meta }
|
|
150
|
+
: { resource: params.resource, variables })));
|
|
151
|
+
return { data: records.map((r) => r.data) };
|
|
152
|
+
}
|
|
153
|
+
async function updateMany(params) {
|
|
154
|
+
const meta = params.meta;
|
|
155
|
+
const variables = params.variables;
|
|
156
|
+
const records = await Promise.all(params.ids.map((id) => update(meta
|
|
157
|
+
? { resource: params.resource, id, variables, meta }
|
|
158
|
+
: { resource: params.resource, id, variables })));
|
|
159
|
+
return { data: records.map((r) => r.data) };
|
|
160
|
+
}
|
|
161
|
+
async function deleteMany(params) {
|
|
162
|
+
const meta = params.meta;
|
|
163
|
+
const variables = params.variables;
|
|
164
|
+
const records = await Promise.all(params.ids.map((id) => deleteOne(meta || variables
|
|
165
|
+
? {
|
|
166
|
+
resource: params.resource,
|
|
167
|
+
id,
|
|
168
|
+
...(variables ? { variables } : {}),
|
|
169
|
+
...(meta ? { meta } : {}),
|
|
170
|
+
}
|
|
171
|
+
: { resource: params.resource, id })));
|
|
172
|
+
return { data: records.map((r) => r.data) };
|
|
173
|
+
}
|
|
174
|
+
async function custom(params) {
|
|
175
|
+
const procedureName = params.meta?.procedure;
|
|
176
|
+
const procedureFn = procedureName ? options.procedures?.[procedureName] : undefined;
|
|
177
|
+
if (typeof procedureFn !== "function") {
|
|
178
|
+
throw new Error('custom() needs meta: { procedure: "<name>" } naming an entry in the "procedures" map ' +
|
|
179
|
+
"passed to createCratestackDataProvider");
|
|
180
|
+
}
|
|
181
|
+
const data = await procedureFn(params.payload ?? {});
|
|
182
|
+
return { data: data };
|
|
183
|
+
}
|
|
184
|
+
// Cast, not a structural coincidence: `DataProvider`'s methods are
|
|
185
|
+
// individually generic over a caller-chosen `TData extends BaseRecord`
|
|
186
|
+
// (so a caller can write `getOne<Widget>(...)`), but this factory
|
|
187
|
+
// returns the SAME concrete implementation regardless of what a caller
|
|
188
|
+
// instantiates TData as — every method already returns a real
|
|
189
|
+
// `BaseRecord`-shaped value built from the real decoded response, and
|
|
190
|
+
// relies on the caller's own generic parameter for compile-time
|
|
191
|
+
// narrowing at the call site, exactly like every other hand-written
|
|
192
|
+
// `DataProvider` implementation (refine's own generic method shape
|
|
193
|
+
// isn't satisfiable by a concrete non-generic function under
|
|
194
|
+
// `exactOptionalPropertyTypes`, a known TypeScript variance gap, not a
|
|
195
|
+
// real type-safety hole here).
|
|
196
|
+
return {
|
|
197
|
+
getApiUrl: options.getApiUrl ?? (() => ""),
|
|
198
|
+
getList,
|
|
199
|
+
getOne,
|
|
200
|
+
getMany,
|
|
201
|
+
create,
|
|
202
|
+
createMany,
|
|
203
|
+
update,
|
|
204
|
+
updateMany,
|
|
205
|
+
deleteOne,
|
|
206
|
+
deleteMany,
|
|
207
|
+
custom,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAElG,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,yEAAyE;AACzE,uEAAuE;AACvE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAqBpE,SAAS,YAAY,CAAC,MAAW,EAAE,UAAkB;IACnD,qEAAqE;IACrE,uEAAuE;IACvE,qEAAqE;IACrE,uEAAuE;IACvE,0BAA0B;IAC1B,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,CAAY,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,eAAe,CAAC,SAAsB,EAAE,QAAgB;IAC/D,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,0CAA0C,QAAQ,oCAAoC;YACpF,wCAAwC,CAC3C,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAiBD;;;;;;;;;;;;;kBAakB;AAClB,MAAM,UAAU,4BAA4B,CAC1C,SAA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I,EAAE,SAA+B,CAAC;QACnE,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpF,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,uFAAuF;gBACrF,wCAAwC,CAC3C,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACrD,OAAO,EAAE,IAAI,EAAE,IAAkB,EAAE,CAAC;IACtC,CAAC;IAED,mEAAmE;IACnE,uEAAuE;IACvE,kEAAkE;IAClE,uEAAuE;IACvE,8DAA8D;IAC9D,sEAAsE;IACtE,gEAAgE;IAChE,oEAAoE;IACpE,mEAAmE;IACnE,6DAA6D;IAC7D,uEAAuE;IACvE,+BAA+B;IAC/B,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;QAC1C,OAAO;QACP,MAAM;QACN,OAAO;QACP,MAAM;QACN,UAAU;QACV,MAAM;QACN,UAAU;QACV,SAAS;QACT,UAAU;QACV,MAAM;KACS,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CrudFilters, CrudSorting } from "@refinedev/core";
|
|
2
|
+
import type { RpcListPredicate } from "./rpc-types.js";
|
|
3
|
+
/** Converts refine's `CrudFilters` into `RpcListPredicate[]` — the RPC
|
|
4
|
+
* list route's typed equivalent of REST's `field__operator=value` query
|
|
5
|
+
* params (`toQueryFilters` in `filters.ts`). Same operator table, same
|
|
6
|
+
* `field[__suffix]` key on each predicate's `key`, same throw-don't-drop
|
|
7
|
+
* behavior for an unsupported operator or a refine filter group — see
|
|
8
|
+
* `filter-operators.ts` for why the two transports share the mapping
|
|
9
|
+
* rather than each defining their own, and
|
|
10
|
+
* `crates/cratestack-axum/src/rpc/synthesize.rs` for the server-side
|
|
11
|
+
* proof that an `RpcListPredicate.key` is spread onto the same
|
|
12
|
+
* `field__op=value` query string REST's `field__operator` convention
|
|
13
|
+
* parses. */
|
|
14
|
+
export declare function toRpcQueryFilters(filters?: CrudFilters): RpcListPredicate[];
|
|
15
|
+
/** refine `CrudSorting` -> the RPC list route's `sort` value: the same
|
|
16
|
+
* `field`/`-field` comma-joined DSL as REST's `toSortQuery` (confirmed
|
|
17
|
+
* against `crates/cratestack-macros/src/axum/model/serializers.rs`'s
|
|
18
|
+
* `sort.split(',')` parsing, shared by both transports since RPC
|
|
19
|
+
* synthesizes a REST-shaped query string server-side), sent as a single
|
|
20
|
+
* already-joined string instead of REST's `string[]` — the one place
|
|
21
|
+
* `CratestackRpcListQuery` and `CratestackFetchQuery` genuinely diverge
|
|
22
|
+
* in shape (`RpcListInput.sort: Option<String>` vs. an array joined
|
|
23
|
+
* client-side by REST's own runtime). */
|
|
24
|
+
export declare function toRpcSortQuery(sorters?: CrudSorting): string | undefined;
|
|
25
|
+
//# sourceMappingURL=rpc-filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-filters.d.ts","sourceRoot":"","sources":["../src/rpc-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;;;;;;;;cAUc;AACd,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,WAAgB,GAAG,gBAAgB,EAAE,CAc/E;AAED;;;;;;;;0CAQ0C;AAC1C,wBAAgB,cAAc,CAAC,OAAO,GAAE,WAAgB,GAAG,MAAM,GAAG,SAAS,CAG5E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { filterValue, requireOperatorSuffix } from "./filter-operators.js";
|
|
2
|
+
/** Converts refine's `CrudFilters` into `RpcListPredicate[]` — the RPC
|
|
3
|
+
* list route's typed equivalent of REST's `field__operator=value` query
|
|
4
|
+
* params (`toQueryFilters` in `filters.ts`). Same operator table, same
|
|
5
|
+
* `field[__suffix]` key on each predicate's `key`, same throw-don't-drop
|
|
6
|
+
* behavior for an unsupported operator or a refine filter group — see
|
|
7
|
+
* `filter-operators.ts` for why the two transports share the mapping
|
|
8
|
+
* rather than each defining their own, and
|
|
9
|
+
* `crates/cratestack-axum/src/rpc/synthesize.rs` for the server-side
|
|
10
|
+
* proof that an `RpcListPredicate.key` is spread onto the same
|
|
11
|
+
* `field__op=value` query string REST's `field__operator` convention
|
|
12
|
+
* parses. */
|
|
13
|
+
export function toRpcQueryFilters(filters = []) {
|
|
14
|
+
const output = [];
|
|
15
|
+
for (const filter of filters) {
|
|
16
|
+
if (!("field" in filter)) {
|
|
17
|
+
throw new Error(`refine "${filter.operator}" filter groups have no cratestack equivalent — ` +
|
|
18
|
+
"this dataProvider only supports a flat AND of per-field predicates");
|
|
19
|
+
}
|
|
20
|
+
const suffix = requireOperatorSuffix(filter.field, filter.operator);
|
|
21
|
+
const key = suffix ? `${filter.field}__${suffix}` : filter.field;
|
|
22
|
+
output.push({ key, value: filterValue(filter.operator, filter.value) });
|
|
23
|
+
}
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
/** refine `CrudSorting` -> the RPC list route's `sort` value: the same
|
|
27
|
+
* `field`/`-field` comma-joined DSL as REST's `toSortQuery` (confirmed
|
|
28
|
+
* against `crates/cratestack-macros/src/axum/model/serializers.rs`'s
|
|
29
|
+
* `sort.split(',')` parsing, shared by both transports since RPC
|
|
30
|
+
* synthesizes a REST-shaped query string server-side), sent as a single
|
|
31
|
+
* already-joined string instead of REST's `string[]` — the one place
|
|
32
|
+
* `CratestackRpcListQuery` and `CratestackFetchQuery` genuinely diverge
|
|
33
|
+
* in shape (`RpcListInput.sort: Option<String>` vs. an array joined
|
|
34
|
+
* client-side by REST's own runtime). */
|
|
35
|
+
export function toRpcSortQuery(sorters = []) {
|
|
36
|
+
if (sorters.length === 0)
|
|
37
|
+
return undefined;
|
|
38
|
+
return sorters.map((s) => (s.order === "desc" ? `-${s.field}` : s.field)).join(",");
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=rpc-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-filters.js","sourceRoot":"","sources":["../src/rpc-filters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG3E;;;;;;;;;;cAUc;AACd,MAAM,UAAU,iBAAiB,CAAC,OAAO,GAAgB,EAAE;IACzD,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,CAAC,QAAQ,kDAAkD;gBAC1E,oEAAoE,CACvE,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACjE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;0CAQ0C;AAC1C,MAAM,UAAU,cAAc,CAAC,OAAO,GAAgB,EAAE;IACtD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CreateManyParams, CreateManyResponse, CreateParams, CreateResponse, DeleteManyParams, DeleteManyResponse, DeleteOneParams, DeleteOneResponse, UpdateManyParams, UpdateManyResponse, UpdateParams, UpdateResponse } from "@refinedev/core";
|
|
2
|
+
/** `createMany`/`updateMany`/`deleteMany`, factored out of
|
|
3
|
+
* `rpc-provider.ts` because the N-sequential-round-trips-via-`Promise.all`
|
|
4
|
+
* strategy is entirely refine-shaped, not RPC-shaped — it just replays
|
|
5
|
+
* the single-record `create`/`update`/`deleteOne` closure N times, so it
|
|
6
|
+
* doesn't need to know which transport those closures talk over. Same
|
|
7
|
+
* strategy REST's `createCratestackDataProvider` uses inline (not
|
|
8
|
+
* reused from here, to keep this change additive rather than touching
|
|
9
|
+
* already-shipped REST code) — see that file's own comment for why this
|
|
10
|
+
* is IMPLEMENTED, not declined: real behavior, just not atomic or
|
|
11
|
+
* batched (`/rpc/batch` exists on this transport, but batching would
|
|
12
|
+
* make per-frame `If-Match` inexpressible — see `rpc-provider.ts`). */
|
|
13
|
+
export declare function runCreateMany(params: CreateManyParams, create: (p: CreateParams) => Promise<CreateResponse>): Promise<CreateManyResponse>;
|
|
14
|
+
export declare function runUpdateMany(params: UpdateManyParams, update: (p: UpdateParams) => Promise<UpdateResponse>): Promise<UpdateManyResponse>;
|
|
15
|
+
export declare function runDeleteMany(params: DeleteManyParams, deleteOne: (p: DeleteOneParams) => Promise<DeleteOneResponse>): Promise<DeleteManyResponse>;
|
|
16
|
+
//# sourceMappingURL=rpc-many.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-many.d.ts","sourceRoot":"","sources":["../src/rpc-many.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;wEAUwE;AACxE,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GACnD,OAAO,CAAC,kBAAkB,CAAC,CAY7B;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GACnD,OAAO,CAAC,kBAAkB,CAAC,CAa7B;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,CAAC,GAC5D,OAAO,CAAC,kBAAkB,CAAC,CAkB7B"}
|
package/dist/rpc-many.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** `createMany`/`updateMany`/`deleteMany`, factored out of
|
|
2
|
+
* `rpc-provider.ts` because the N-sequential-round-trips-via-`Promise.all`
|
|
3
|
+
* strategy is entirely refine-shaped, not RPC-shaped — it just replays
|
|
4
|
+
* the single-record `create`/`update`/`deleteOne` closure N times, so it
|
|
5
|
+
* doesn't need to know which transport those closures talk over. Same
|
|
6
|
+
* strategy REST's `createCratestackDataProvider` uses inline (not
|
|
7
|
+
* reused from here, to keep this change additive rather than touching
|
|
8
|
+
* already-shipped REST code) — see that file's own comment for why this
|
|
9
|
+
* is IMPLEMENTED, not declined: real behavior, just not atomic or
|
|
10
|
+
* batched (`/rpc/batch` exists on this transport, but batching would
|
|
11
|
+
* make per-frame `If-Match` inexpressible — see `rpc-provider.ts`). */
|
|
12
|
+
export async function runCreateMany(params, create) {
|
|
13
|
+
const meta = params.meta;
|
|
14
|
+
const records = await Promise.all(params.variables.map((variables) => create(meta
|
|
15
|
+
? { resource: params.resource, variables, meta }
|
|
16
|
+
: { resource: params.resource, variables })));
|
|
17
|
+
return { data: records.map((r) => r.data) };
|
|
18
|
+
}
|
|
19
|
+
export async function runUpdateMany(params, update) {
|
|
20
|
+
const meta = params.meta;
|
|
21
|
+
const variables = params.variables;
|
|
22
|
+
const records = await Promise.all(params.ids.map((id) => update(meta
|
|
23
|
+
? { resource: params.resource, id, variables, meta }
|
|
24
|
+
: { resource: params.resource, id, variables })));
|
|
25
|
+
return { data: records.map((r) => r.data) };
|
|
26
|
+
}
|
|
27
|
+
export async function runDeleteMany(params, deleteOne) {
|
|
28
|
+
const meta = params.meta;
|
|
29
|
+
const variables = params.variables;
|
|
30
|
+
const records = await Promise.all(params.ids.map((id) => deleteOne(meta || variables
|
|
31
|
+
? {
|
|
32
|
+
resource: params.resource,
|
|
33
|
+
id,
|
|
34
|
+
...(variables ? { variables } : {}),
|
|
35
|
+
...(meta ? { meta } : {}),
|
|
36
|
+
}
|
|
37
|
+
: { resource: params.resource, id })));
|
|
38
|
+
return { data: records.map((r) => r.data) };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=rpc-many.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-many.js","sourceRoot":"","sources":["../src/rpc-many.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;wEAUwE;AACxE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAwB,EACxB,MAAoD;IAEpD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC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,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACpB,SAAS,CACP,IAAI,IAAI,SAAS;QACf,CAAC,CAAC;YACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,EAAE;YACF,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1B;QACH,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,CACtC,CACF,CACF,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DataProvider } from "@refinedev/core";
|
|
2
|
+
import type { RpcResourceMap } from "./rpc-types.js";
|
|
3
|
+
export interface CreateCratestackRpcDataProviderOptions {
|
|
4
|
+
/** Backs `getApiUrl()`. Defaults to `() => ""`, same as the REST
|
|
5
|
+
* provider — see `CreateCratestackDataProviderOptions.getApiUrl` in
|
|
6
|
+
* `index.ts` for why refine rarely calls this in practice. */
|
|
7
|
+
getApiUrl?: () => string;
|
|
8
|
+
/** Backs `custom()` — identical contract to the REST provider's
|
|
9
|
+
* `procedures` option (`CreateCratestackDataProviderOptions.procedures`
|
|
10
|
+
* in `index.ts`): keyed by procedure name, called as
|
|
11
|
+
* `client.procedures.<name>` would be. */
|
|
12
|
+
procedures?: Record<string, (args: unknown) => Promise<unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/** Builds a refine `DataProvider` over one or more `transport rpc`
|
|
15
|
+
* cratestack generated model classes (`client.widgets`, `client.ledgers`,
|
|
16
|
+
* …) — the RPC sibling of `createCratestackDataProvider` in `index.ts`.
|
|
17
|
+
* Same manifest shape (`RpcResourceMap`), same filter/pagination/
|
|
18
|
+
* primary-key/optimistic-locking semantics; only the wire calls
|
|
19
|
+
* underneath differ, because the generated RPC client's `list` takes its
|
|
20
|
+
* query positionally instead of nested in an options object (see
|
|
21
|
+
* `rpc-types.ts`'s `CratestackRpcModelApi` doc comment).
|
|
22
|
+
*
|
|
23
|
+
* Deliberately uses only unary `POST /rpc/{op_id}` calls, never
|
|
24
|
+
* `POST /rpc/batch` — a batch request is a single HTTP request carrying
|
|
25
|
+
* N frames, so a per-frame `If-Match` header (what `@version` optimistic
|
|
26
|
+
* locking needs) is not expressible there. `createMany`/`updateMany`/
|
|
27
|
+
* `deleteMany` below are N real unary round trips for exactly that
|
|
28
|
+
* reason, same as REST's non-atomic N-round-trip strategy. */
|
|
29
|
+
export declare function createCratestackRpcDataProvider(resources: RpcResourceMap, options?: CreateCratestackRpcDataProviderOptions): DataProvider;
|
|
30
|
+
//# sourceMappingURL=rpc-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-provider.d.ts","sourceRoot":"","sources":["../src/rpc-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EASV,YAAY,EAeb,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAA6C,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAuBhG,MAAM,WAAW,sCAAsC;IACrD;;mEAE+D;IAC/D,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;IACzB;;;+CAG2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CAClE;AAED;;;;;;;;;;;;;;+DAc+D;AAC/D,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,sCAA2C,GACnD,YAAY,CAsJd"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { toRefineError } from "./errors.js";
|
|
2
|
+
import { toRpcQueryFilters, toRpcSortQuery } from "./rpc-filters.js";
|
|
3
|
+
import { runCreateMany, runDeleteMany, runUpdateMany } from "./rpc-many.js";
|
|
4
|
+
import { createVersionCache, forgetVersion, ifMatchHeaders, rememberVersion } from "./version.js";
|
|
5
|
+
function withRefineId(record, primaryKey) {
|
|
6
|
+
// Same honest cast as REST's `withRefineId` in `index.ts` — see that
|
|
7
|
+
// function's doc comment.
|
|
8
|
+
return { ...record, id: record[primaryKey] };
|
|
9
|
+
}
|
|
10
|
+
function requireResource(resources, resource) {
|
|
11
|
+
const config = resources[resource];
|
|
12
|
+
if (!config) {
|
|
13
|
+
throw new Error(`no cratestack resource configured for "${resource}" — add it to the "resources" map ` +
|
|
14
|
+
"passed to createCratestackRpcDataProvider");
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
/** Builds a refine `DataProvider` over one or more `transport rpc`
|
|
19
|
+
* cratestack generated model classes (`client.widgets`, `client.ledgers`,
|
|
20
|
+
* …) — the RPC sibling of `createCratestackDataProvider` in `index.ts`.
|
|
21
|
+
* Same manifest shape (`RpcResourceMap`), same filter/pagination/
|
|
22
|
+
* primary-key/optimistic-locking semantics; only the wire calls
|
|
23
|
+
* underneath differ, because the generated RPC client's `list` takes its
|
|
24
|
+
* query positionally instead of nested in an options object (see
|
|
25
|
+
* `rpc-types.ts`'s `CratestackRpcModelApi` doc comment).
|
|
26
|
+
*
|
|
27
|
+
* Deliberately uses only unary `POST /rpc/{op_id}` calls, never
|
|
28
|
+
* `POST /rpc/batch` — a batch request is a single HTTP request carrying
|
|
29
|
+
* N frames, so a per-frame `If-Match` header (what `@version` optimistic
|
|
30
|
+
* locking needs) is not expressible there. `createMany`/`updateMany`/
|
|
31
|
+
* `deleteMany` below are N real unary round trips for exactly that
|
|
32
|
+
* reason, same as REST's non-atomic N-round-trip strategy. */
|
|
33
|
+
export function createCratestackRpcDataProvider(resources, options = {}) {
|
|
34
|
+
const versionCache = createVersionCache();
|
|
35
|
+
async function getList(params) {
|
|
36
|
+
const config = requireResource(resources, params.resource);
|
|
37
|
+
const usePaging = config.paged && params.pagination?.mode !== "off";
|
|
38
|
+
const currentPage = params.pagination?.currentPage ?? 1;
|
|
39
|
+
const pageSize = params.pagination?.pageSize ?? 10;
|
|
40
|
+
const sort = toRpcSortQuery(params.sorters);
|
|
41
|
+
const query = {
|
|
42
|
+
filters: toRpcQueryFilters(params.filters),
|
|
43
|
+
...(sort ? { sort } : {}),
|
|
44
|
+
...(usePaging ? { limit: pageSize, offset: (currentPage - 1) * pageSize } : {}),
|
|
45
|
+
};
|
|
46
|
+
const result = await config.api.list(query);
|
|
47
|
+
const items = config.paged ? result.items : result;
|
|
48
|
+
for (const item of items) {
|
|
49
|
+
rememberVersion(versionCache, params.resource, item[config.primaryKey], item, config);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
data: items.map((item) => withRefineId(item, config.primaryKey)),
|
|
53
|
+
total: config.paged
|
|
54
|
+
? (result.totalCount ?? items.length)
|
|
55
|
+
: items.length,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function getOne(params) {
|
|
59
|
+
const config = requireResource(resources, params.resource);
|
|
60
|
+
try {
|
|
61
|
+
const record = (await config.api.get(params.id));
|
|
62
|
+
rememberVersion(versionCache, params.resource, params.id, record, config);
|
|
63
|
+
return { data: withRefineId(record, config.primaryKey) };
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw toRefineError(error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Same one-list-call-instead-of-N-getOne-calls strategy as REST's
|
|
70
|
+
// `getMany` — see that function's comment in `index.ts`.
|
|
71
|
+
async function getMany(params) {
|
|
72
|
+
const config = requireResource(resources, params.resource);
|
|
73
|
+
const query = {
|
|
74
|
+
filters: [{ key: `${config.primaryKey}__in`, value: params.ids.map(String).join(",") }],
|
|
75
|
+
};
|
|
76
|
+
const result = await config.api.list(query);
|
|
77
|
+
const items = config.paged ? result.items : result;
|
|
78
|
+
for (const item of items) {
|
|
79
|
+
rememberVersion(versionCache, params.resource, item[config.primaryKey], item, config);
|
|
80
|
+
}
|
|
81
|
+
return { data: items.map((item) => withRefineId(item, config.primaryKey)) };
|
|
82
|
+
}
|
|
83
|
+
async function create(params) {
|
|
84
|
+
const config = requireResource(resources, params.resource);
|
|
85
|
+
if (!config.api.create) {
|
|
86
|
+
throw new Error(`"${params.resource}" has no generated create route — its model declares no ` +
|
|
87
|
+
'@@allow("create", ...) policy');
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const record = (await config.api.create(params.variables));
|
|
91
|
+
rememberVersion(versionCache, params.resource, record[config.primaryKey], record, config);
|
|
92
|
+
return { data: withRefineId(record, config.primaryKey) };
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
throw toRefineError(error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function update(params) {
|
|
99
|
+
const config = requireResource(resources, params.resource);
|
|
100
|
+
const headers = ifMatchHeaders(versionCache, params.resource, params.id, config, params.meta?.ifMatch);
|
|
101
|
+
try {
|
|
102
|
+
const record = (await config.api.update(params.id, params.variables, { headers }));
|
|
103
|
+
rememberVersion(versionCache, params.resource, params.id, record, config);
|
|
104
|
+
return { data: withRefineId(record, config.primaryKey) };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw toRefineError(error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function deleteOne(params) {
|
|
111
|
+
const config = requireResource(resources, params.resource);
|
|
112
|
+
const headers = ifMatchHeaders(versionCache, params.resource, params.id, config, params.meta?.ifMatch);
|
|
113
|
+
try {
|
|
114
|
+
await config.api.delete(params.id, { headers });
|
|
115
|
+
return { data: { id: params.id } };
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw toRefineError(error);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
forgetVersion(versionCache, params.resource, params.id);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function createMany(params) {
|
|
125
|
+
return runCreateMany(params, create);
|
|
126
|
+
}
|
|
127
|
+
async function updateMany(params) {
|
|
128
|
+
return runUpdateMany(params, update);
|
|
129
|
+
}
|
|
130
|
+
async function deleteMany(params) {
|
|
131
|
+
return runDeleteMany(params, deleteOne);
|
|
132
|
+
}
|
|
133
|
+
async function custom(params) {
|
|
134
|
+
const procedureName = params.meta?.procedure;
|
|
135
|
+
const procedureFn = procedureName ? options.procedures?.[procedureName] : undefined;
|
|
136
|
+
if (typeof procedureFn !== "function") {
|
|
137
|
+
throw new Error('custom() needs meta: { procedure: "<name>" } naming an entry in the "procedures" map ' +
|
|
138
|
+
"passed to createCratestackRpcDataProvider");
|
|
139
|
+
}
|
|
140
|
+
const data = await procedureFn(params.payload ?? {});
|
|
141
|
+
return { data: data };
|
|
142
|
+
}
|
|
143
|
+
// Same cast, same reasoning as REST's `createCratestackDataProvider` —
|
|
144
|
+
// see that function's closing comment in `index.ts`.
|
|
145
|
+
return {
|
|
146
|
+
getApiUrl: options.getApiUrl ?? (() => ""),
|
|
147
|
+
getList,
|
|
148
|
+
getOne,
|
|
149
|
+
getMany,
|
|
150
|
+
create,
|
|
151
|
+
createMany,
|
|
152
|
+
update,
|
|
153
|
+
updateMany,
|
|
154
|
+
deleteOne,
|
|
155
|
+
deleteMany,
|
|
156
|
+
custom,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=rpc-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-provider.js","sourceRoot":"","sources":["../src/rpc-provider.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,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