@asteby/metacore-dataload 0.0.0-stage → 0.1.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.
Files changed (67) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +89 -2
  3. package/dist/api.d.ts +87 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +141 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/capabilities.d.ts +27 -0
  8. package/dist/capabilities.d.ts.map +1 -0
  9. package/dist/capabilities.js +26 -0
  10. package/dist/capabilities.js.map +1 -0
  11. package/dist/context.d.ts +35 -0
  12. package/dist/context.d.ts.map +1 -0
  13. package/dist/context.js +22 -0
  14. package/dist/context.js.map +1 -0
  15. package/dist/dataload-launcher.d.ts +33 -0
  16. package/dist/dataload-launcher.d.ts.map +1 -0
  17. package/dist/dataload-launcher.js +125 -0
  18. package/dist/dataload-launcher.js.map +1 -0
  19. package/dist/hooks.d.ts +122 -0
  20. package/dist/hooks.d.ts.map +1 -0
  21. package/dist/hooks.js +358 -0
  22. package/dist/hooks.js.map +1 -0
  23. package/dist/index.d.ts +15 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +15 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/media-backup-panel.d.ts +13 -0
  28. package/dist/media-backup-panel.d.ts.map +1 -0
  29. package/dist/media-backup-panel.js +47 -0
  30. package/dist/media-backup-panel.js.map +1 -0
  31. package/dist/messages.d.ts +510 -0
  32. package/dist/messages.d.ts.map +1 -0
  33. package/dist/messages.js +525 -0
  34. package/dist/messages.js.map +1 -0
  35. package/dist/overrides-editor.d.ts +43 -0
  36. package/dist/overrides-editor.d.ts.map +1 -0
  37. package/dist/overrides-editor.js +159 -0
  38. package/dist/overrides-editor.js.map +1 -0
  39. package/dist/overrides.d.ts +50 -0
  40. package/dist/overrides.d.ts.map +1 -0
  41. package/dist/overrides.js +152 -0
  42. package/dist/overrides.js.map +1 -0
  43. package/dist/plan-review.d.ts +15 -0
  44. package/dist/plan-review.d.ts.map +1 -0
  45. package/dist/plan-review.js +48 -0
  46. package/dist/plan-review.js.map +1 -0
  47. package/dist/review-queue.d.ts +27 -0
  48. package/dist/review-queue.d.ts.map +1 -0
  49. package/dist/review-queue.js +120 -0
  50. package/dist/review-queue.js.map +1 -0
  51. package/dist/types.d.ts +475 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +27 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/ui.d.ts +43 -0
  56. package/dist/ui.d.ts.map +1 -0
  57. package/dist/ui.js +61 -0
  58. package/dist/ui.js.map +1 -0
  59. package/dist/upload.d.ts +55 -0
  60. package/dist/upload.d.ts.map +1 -0
  61. package/dist/upload.js +139 -0
  62. package/dist/upload.js.map +1 -0
  63. package/dist/utils.d.ts +46 -0
  64. package/dist/utils.d.ts.map +1 -0
  65. package/dist/utils.js +116 -0
  66. package/dist/utils.js.map +1 -0
  67. package/package.json +51 -3
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Asteby, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # @asteby/metacore-dataload
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Typed client, hooks and UI for the kernel's generic bulk-load engine (`metacore-kernel/dataload`): declarative profiles and per-organization overrides, **dry-run and diff**, idempotent asynchronous runs with progress and history, a **review queue** for rows the extract stage held, **chunked uploads** for big files, and the status of the **immutable sha256 media backup**.
4
+
5
+ No niche, source-platform or flavor logic lives here: everything specific (a mapping from some source, an org's ignored columns, review codes) is a declarative profile / override / extract document registered by the host.
6
+
7
+ ## Contract
8
+
9
+ The kernel package has no HTTP layer; the host (ops / an addon) mounts a handler at `basePath` (default `/dataload`) wrapping `dataload.Runner`, `Ledger`, `ReviewStore`, `Manifest` and `MediaQueue`. Responses use the usual `{ success, data }` envelope; errors carry `{ message }` and an HTTP status.
10
+
11
+ | Method | Path | Kernel call | Returns |
12
+ | --- | --- | --- | --- |
13
+ | GET | `/profiles` | every published version (shared base catalog + the organization's) | `ProfileSummary[]` |
14
+ | GET | `/profiles/:name/versions/:version[?base=1]` | one full version | `StoredProfileVersion` |
15
+ | POST | `/profiles` `{ name, version, profile? \| base + overrides, extract?, note? }` | `Registry.Publish` (immutable; same content = no-op, other content = 409) | `StoredProfileVersion` |
16
+ | POST | `/dry-run` | `Runner.DryRun` | `{ plan, run, source }` (`source` = id of the stored source) |
17
+ | POST | `/runs` | `Runner.Start` (returns at once) | `DataloadRun` |
18
+ | GET | `/runs?limit=` | `Ledger.List` | `DataloadRun[]` |
19
+ | GET | `/runs/:id` | `Runner.Status` | `DataloadRun` |
20
+ | GET | `/runs/:id/plan?action=&offset=&limit=` | page of the plan stored with the run (server default 100) | `PlanPage` |
21
+ | POST | `/runs/:id/cancel` | `Runner.Cancel` | `DataloadRun` |
22
+ | GET | `/reviews?entity=&state=&run_id=&code=&limit=&cursor=` | `ReviewStore.List` (cursor pages, limit ≤ 500) | `ReviewPage` (`items`, `counts`, `next`) |
23
+ | POST | `/reviews/decide` `{ decisions: ReviewDecision[] }` | `Runner.Decide` (all or nothing) | `ReviewEntry[]` |
24
+ | POST | `/reviews/apply` `{ entity }` | `Runner.ApplyApproved` | `DataloadRun` (`mode: apply_reviewed`) |
25
+ | POST | `/uploads` `{ name, size, contentType?, chunkSize? }` | host storage | `UploadSession` |
26
+ | GET | `/uploads/:id` | host storage | `UploadSession` (with `received` parts) |
27
+ | POST | `/uploads/:id/parts/:index` raw bytes | host storage | — |
28
+ | POST | `/uploads/:id/complete` `{ sha256? }` | host storage | `UploadSession` (with `sha256`) |
29
+ | POST | `/uploads/:id/abort` | host storage | — |
30
+ | GET | `/media/status?run_id=` | `MediaQueue.Stats` + manifest summary + dead jobs | `MediaBackupStatus` |
31
+ | GET | `/media/manifest` | `ExportManifest` | `ManifestEntry[]` |
32
+ | POST | `/media/verify` | `Backuper.VerifyAll` | `VerifyReport` |
33
+ | POST | `/media/retry` `{ run_id? }` | `MediaQueue.RetryFailed` | `{ requeued }` |
34
+
35
+ `dry-run` and `runs` take `{ profile: ref | inline profile, overrides?, source }`, where `ref` is `name@version` (the organization's) or `base/name@version` (the shared catalog, see `profileRef`) and `source` is `{ id }` (a source the server already stored: what the first dry-run returns), `{ format: 'csv'|'json'|'bundle', name, content, path? }` (inline text) or `{ format, name, uploadId, path? }` (a completed chunked upload); `runs` also takes `force`, `failOnInvalid` and **`expectPlanHash`**. The launcher applies exactly what was simulated: the registry version the dry-run resolved (`run.registry`), the stored source id (nothing is re-sent, so an import costs one upload) and the reviewed `planHash`; if the plan the server would apply now is different it answers **409** (`isPlanChanged`) and the UI drops the plan and asks to simulate again. Edited overrides are the complete set and go over the full base profile of the selected version. `src/__fixtures__/ops/` holds the server's real responses and `contract.test.ts` checks the client against them. An explicit `overrides: {}` means "no overrides" (omitting it lets the server use the ones stored with the profile). The organization and the actor always come from the session, never from the body. Tokens and passwords are never part of any payload.
36
+
37
+ **Reviews.** A decision carries the `hash` of the row the person saw; the server answers **409** when the row changed since (`ErrReviewStale`) or is closed (`ErrReviewClosed`), and the UI reloads the queue. Approved rows are written only by `/reviews/apply`.
38
+
39
+ **Chunked uploads.** The server chooses (or caps) `chunkSize` and answers which parts it already has, so an interrupted upload resumes without resending them. Each part is sent as `application/octet-stream` with `X-Content-Sha256` (hex) when the browser has WebCrypto, so the server can reject a corrupted part; parts can arrive again (idempotent by index). `complete` assembles the file and returns its sha256. The client never continues an upload whose `size` or `name` differ from the picked file (it discards it and starts a new one, so parts of two files are never mixed), and it refuses a `chunkSize` above 64 MB (each part is held in memory to hash it). The server should expire unfinished uploads. The row cap of the profile (`maxRows`) still applies when the file is read.
40
+
41
+ ## Use
42
+
43
+ ```tsx
44
+ import { createDataloadApi, DataloadLauncher, DataloadProvider } from '@asteby/metacore-dataload'
45
+
46
+ const api = createDataloadApi(axiosInstance) // or { basePath: '/api/dataload' }
47
+
48
+ <DataloadProvider locale='es-MX' capabilities={capsFromRole} notify={toast}>
49
+ <DataloadLauncher api={api} defaultProfile='catalogo' onFinished={(run) => ...} />
50
+ </DataloadProvider>
51
+ ```
52
+
53
+ A complete host page (roles to capabilities, review screen, settings screen, plugging i18next) is in [`example/dataload-page.tsx`](./example/dataload-page.tsx).
54
+
55
+ Components: `DataloadLauncher` (everything below in one flow), `PlanReview`, `RunProgressView`, `ReviewQueue`, `OverridesEditor`, `MediaBackupPanel`. Each accepts `t`, `locale`, `messages`, `capabilities` and `notify`, which win over `DataloadProvider`.
56
+
57
+ Hooks for custom screens: `useDataloadLauncher` (pick -> dry-run -> review -> execute state machine, with `setOverrides`), `useSourceFile` (inline or chunked, with `cancel` / `retry`), `useDataloadProfiles`, `useDataloadRuns`, `useDataloadRun` (polls until terminal), `useDataloadRunPlan`, `useDataloadReviews`, `useReviewActions` (decide, apply approved), `useMediaBackupStatus`, `useDataloadActions` (cancel, verify, retry media).
58
+
59
+ Pure helpers: `summarizePlan`, `filterRows`, `canApply`, `progressPercent`, `parseTime` (the kernel serializes unset times as `0001-01-01`), `mediaHealth`, `readSourceFile`, `uploadSourceFile`, `validateOverrides`, `resolveProfile`, `compactOverrides`, `resolveCapabilities`, `makeT`.
60
+
61
+ ### Review queue
62
+
63
+ `ReviewQueue` lists the rows held for review (filter by state and reason code) in a table: row, identity, reasons (`revisar` / `info` with their code, field and detail from the extract document), what applying would do, and the state of the decision (who, when, comment). "Details" shows the field diff from the plan stored with the run that held the row (only if that plan still has the same version of the row) and the record that would be written. Select one or many, add a comment, approve or reject; "Apply approved (N)" writes them. With `hideWhenEmpty` it renders nothing while there is nothing to decide, or when the host has not mounted `/reviews` (404/405/501).
64
+
65
+ ### Overrides editor
66
+
67
+ `OverridesEditor` edits one organization's overrides over a base profile: columns to ignore (exact or `prefix*`), extra headers per field, removed fields (never the identity), default values (typed by the field), and cleaning (replace the global rules, add rules per field, `drop_lines:<regex>`). Full field replacements and value translations are kept as they came. It validates as you type with the kernel's rules (`validateOverrides`: unknown or removed targets, unknown rules, invalid regexes, identity removal, another org's overrides), shows the resolved profile summary, runs a dry-run preview of the plan with the edited overrides when it has a `source`, and saves by publishing a NEW immutable version (`publishVersion`, base + overrides; versions are never rewritten). The server validates again and is the authority (JS RegExp only approximates Go RE2).
68
+
69
+ ### Permissions
70
+
71
+ The host passes what the person may do; the UI hides or disables accordingly (the server must enforce the same rules):
72
+
73
+ | Capability | Without it |
74
+ | --- | --- |
75
+ | `launch` | dry-run is still offered; "Apply" is disabled with an explanation |
76
+ | `cancel` | no "Cancel load" button |
77
+ | `approve` | the review queue is read-only (no selection, decisions or apply) |
78
+ | `retryMedia` | no "Retry failed" in the media panel |
79
+ | `verifyMedia` | no "Verify backup" |
80
+ | `editOverrides` | the overrides editor is read-only and cannot save |
81
+
82
+ Without `capabilities` everything is offered. Once the host passes an object, **any capability it leaves out is denied**, so a capability added in a later version never appears enabled by accident.
83
+
84
+ ### i18n
85
+
86
+ Components never write user-facing text of their own: every string is a key. Built-in catalogs: `DATALOAD_MESSAGES_ES_MX` (default) and `DATALOAD_MESSAGES_EN_US`, picked by `locale` (`en*` -> en-US, anything else -> es-MX). Resolution order per key: `messages[key]` -> `t(key, catalogText)` -> catalog. A `t` that returns the key itself (a missing translation in most libraries) falls back to the catalog. To add a language, pass a full catalog typed as `DataloadMessages` in `messages`. Server messages (validation errors) are shown as the server sends them.
87
+
88
+ ## UI
89
+
90
+ Built on `@asteby/metacore-ui` and the host's design tokens (`bg-card`, `text-muted-foreground`, status badges), so light/dark themes apply with no extra CSS. Single column on phones; diff rows are cards, and wide tables (review queue, fields of a profile) scroll inside a focusable region instead of the page. Fields have labels, focus is visible, tables have a caption and column/row headers, progress is `role=progressbar`, and upload progress, run state and review decisions are announced through `aria-live`.
package/dist/api.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import type { DataloadHttpClient, DataloadPlan, DataloadRequest, DataloadRun, DryRunResult, ExecuteRequest, MediaBackupStatus, ManifestEntry, PlanPage, PlanPageQuery, ProfileKey, ProfileSummary, PublishVersionRequest, ReviewDecision, ReviewEntry, ReviewFilter, ReviewPage, StoredProfileVersion, UploadSession, VerifyReport } from './types';
2
+ /** Reference to send as `profile` in a request: `base/name@version` for the host's shared catalog. */
3
+ export declare function profileRef(p: {
4
+ name: string;
5
+ version: string;
6
+ shared?: boolean;
7
+ org?: string;
8
+ }): string;
9
+ export interface DataloadApi {
10
+ /** Every published version: the host's shared base catalog (`shared`) and the organization's own. */
11
+ listProfiles(): Promise<ProfileSummary[]>;
12
+ /**
13
+ * Publishes a new immutable version (full profile, or base + overrides).
14
+ * Same content again is a no-op; the same name+version with other content is 409.
15
+ */
16
+ publishVersion(body: PublishVersionRequest): Promise<StoredProfileVersion>;
17
+ /** One full published version (`base/` for the host's shared catalog). */
18
+ profileVersion(key: ProfileKey & {
19
+ shared?: boolean;
20
+ }): Promise<StoredProfileVersion>;
21
+ /** Dry-run: reads, maps and diffs against the destination. Writes and downloads nothing. */
22
+ dryRun(body: DataloadRequest): Promise<DryRunResult>;
23
+ /** Starts an async apply and returns immediately; poll `run(id)` for progress. */
24
+ execute(body: ExecuteRequest): Promise<DataloadRun>;
25
+ run(id: string): Promise<DataloadRun>;
26
+ /** One page of the plan stored with a run (dry-run or apply); paginated on the server. */
27
+ runPlan(id: string, query?: PlanPageQuery): Promise<PlanPage>;
28
+ /** History, newest first. */
29
+ runs(limit?: number): Promise<DataloadRun[]>;
30
+ cancel(id: string): Promise<DataloadRun>;
31
+ mediaStatus(runId?: string): Promise<MediaBackupStatus>;
32
+ /** Exports the manifest (source url, sha256, bytes, type, dates, status). */
33
+ mediaManifest(): Promise<ManifestEntry[]>;
34
+ /** Re-reads every backed-up original and compares sha256. */
35
+ mediaVerify(): Promise<VerifyReport>;
36
+ /** Requeues dead media jobs ("retry media"). Returns how many. */
37
+ mediaRetry(runId?: string): Promise<number>;
38
+ /** One page of the rows held for a decision, by row order, with the counts by state. */
39
+ reviews(filter?: ReviewFilter): Promise<ReviewPage>;
40
+ /** Records decisions without writing to the destination. All or nothing (`Runner.Decide`). */
41
+ decideReviews(decisions: ReviewDecision[]): Promise<ReviewEntry[]>;
42
+ /** Writes the approved rows of an entity (`Runner.ApplyApproved`); returns its `apply_reviewed` run. */
43
+ applyApproved(entity: string): Promise<DataloadRun>;
44
+ /** Opens a chunked upload. The server picks (or caps) `chunkSize`. */
45
+ createUpload(body: {
46
+ name: string;
47
+ size: number;
48
+ contentType?: string;
49
+ chunkSize?: number;
50
+ }): Promise<UploadSession>;
51
+ /** Current state of an upload (which parts the server has), to resume. */
52
+ upload(id: string): Promise<UploadSession>;
53
+ /** Sends one part as raw bytes. `sha256` (hex) lets the server reject a corrupted part. */
54
+ uploadPart(id: string, index: number, chunk: Blob, opts?: {
55
+ sha256?: string;
56
+ signal?: AbortSignal;
57
+ }): Promise<void>;
58
+ /** Assembles the parts; the server checks `sha256` when given. */
59
+ completeUpload(id: string, opts?: {
60
+ sha256?: string;
61
+ }): Promise<UploadSession>;
62
+ /** Discards an unfinished upload. */
63
+ abortUpload(id: string): Promise<void>;
64
+ }
65
+ /** The kernel serializes nil slices as null; the UI wants arrays. */
66
+ export declare function normalizePlan<P extends DataloadPlan | PlanPage>(p: P): P;
67
+ export declare function planQuery(q?: PlanPageQuery): string;
68
+ export declare function normalizeRun(r: DataloadRun): DataloadRun;
69
+ export declare function normalizeReview(e: ReviewEntry): ReviewEntry;
70
+ /** Query string for a review filter (snake_case like the rest of the contract). */
71
+ export declare function reviewQuery(f?: ReviewFilter): string;
72
+ /** REST client for the dataload handler that the host mounts at `basePath` (default `/dataload`). */
73
+ export declare function createDataloadApi(http: DataloadHttpClient, opts?: {
74
+ basePath?: string;
75
+ }): DataloadApi;
76
+ /** Extracts the server message from an axios-like error. */
77
+ export declare function apiErrorMessage(err: unknown, fallback: string): string;
78
+ /** HTTP status of an axios-like error, if any. */
79
+ export declare function apiErrorStatus(err: unknown): number | undefined;
80
+ /**
81
+ * The plan the person reviewed is no longer the one the server would apply (409 on
82
+ * execute with `expectPlanHash`): simulate again before applying.
83
+ */
84
+ export declare function isPlanChanged(err: unknown): boolean;
85
+ /** Every page of the review queue (follows `next`), up to `max` rows. */
86
+ export declare function listAllReviews(api: DataloadApi, filter?: ReviewFilter, max?: number): Promise<ReviewPage>;
87
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,aAAa,EACb,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAA;AAKhB,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEvG;AAED,MAAM,WAAW,WAAW;IAC1B,qGAAqG;IACrG,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;IACzC;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAC1E,0EAA0E;IAC1E,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACrF,4FAA4F;IAC5F,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAA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tE;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED,yEAAyE;AACzE,wBAAsB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,GAAE,YAAiB,EAAE,GAAG,SAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAUjH"}
package/dist/api.js ADDED
@@ -0,0 +1,141 @@
1
+ import { parseTime } from './utils';
2
+ const unwrap = (res) => res.data.data;
3
+ /** Reference to send as `profile` in a request: `base/name@version` for the host's shared catalog. */
4
+ export function profileRef(p) {
5
+ return `${p.shared || p.org === '' ? 'base/' : ''}${p.name}@${p.version}`;
6
+ }
7
+ const nz = (v) => v ?? [];
8
+ /** The kernel serializes nil slices as null; the UI wants arrays. */
9
+ export function normalizePlan(p) {
10
+ return {
11
+ ...p,
12
+ counts: p.counts ?? {},
13
+ rows: nz(p.rows).map((r) => ({ ...r, diffs: nz(r.diffs), issues: nz(r.issues), review: nz(r.review) })),
14
+ };
15
+ }
16
+ export function planQuery(q = {}) {
17
+ const p = new URLSearchParams();
18
+ if (q.action)
19
+ p.set('action', q.action);
20
+ if (q.offset)
21
+ p.set('offset', String(q.offset));
22
+ if (q.limit)
23
+ p.set('limit', String(q.limit));
24
+ const s = p.toString();
25
+ return s ? `?${s}` : '';
26
+ }
27
+ /** Go serializes an unset `time.Time` as 0001-01-01T00:00:00Z even with omitempty: drop those fields. */
28
+ function dropUnsetTimes(o, keys) {
29
+ const out = { ...o };
30
+ for (const k of keys) {
31
+ const v = out[k];
32
+ if (v == null || (typeof v === 'string' && !parseTime(v)))
33
+ delete out[k];
34
+ }
35
+ return out;
36
+ }
37
+ export function normalizeRun(r) {
38
+ return dropUnsetTimes({ ...r, issues: nz(r.issues), review: nz(r.review).map((n) => ({ ...n, items: nz(n.items) })) }, ['startedAt', 'finishedAt']);
39
+ }
40
+ export function normalizeReview(e) {
41
+ return dropUnsetTimes({ ...e, items: nz(e.items), record: e.record ?? {} }, ['decidedAt']);
42
+ }
43
+ function normalizeUpload(u) {
44
+ return { ...u, received: nz(u.received) };
45
+ }
46
+ /** Query string for a review filter (snake_case like the rest of the contract). */
47
+ export function reviewQuery(f = {}) {
48
+ const p = new URLSearchParams();
49
+ if (f.entity)
50
+ p.set('entity', f.entity);
51
+ if (f.state)
52
+ p.set('state', f.state);
53
+ if (f.runId)
54
+ p.set('run_id', f.runId);
55
+ if (f.code)
56
+ p.set('code', f.code);
57
+ if (f.limit)
58
+ p.set('limit', String(f.limit));
59
+ if (f.cursor)
60
+ p.set('cursor', f.cursor);
61
+ const s = p.toString();
62
+ return s ? `?${s}` : '';
63
+ }
64
+ function normalizeStatus(s) {
65
+ return { ...s, dead: nz(s.dead) };
66
+ }
67
+ /** REST client for the dataload handler that the host mounts at `basePath` (default `/dataload`). */
68
+ export function createDataloadApi(http, opts = {}) {
69
+ const base = (opts.basePath ?? '/dataload').replace(/\/$/, '');
70
+ const id = (v) => encodeURIComponent(v);
71
+ const q = (runId) => (runId ? `?run_id=${encodeURIComponent(runId)}` : '');
72
+ return {
73
+ listProfiles: async () => nz(unwrap(await http.get(`${base}/profiles`))),
74
+ publishVersion: async (body) => unwrap(await http.post(`${base}/profiles`, body)),
75
+ profileVersion: async (k) => unwrap(await http.get(`${base}/profiles/${id(k.name)}/versions/${id(k.version)}${k.shared || k.org === '' ? '?base=1' : ''}`)),
76
+ dryRun: async (body) => {
77
+ const r = unwrap(await http.post(`${base}/dry-run`, body));
78
+ return { plan: normalizePlan(r.plan), run: normalizeRun(r.run), ...(r.source ? { source: r.source } : {}) };
79
+ },
80
+ execute: async (body) => normalizeRun(unwrap(await http.post(`${base}/runs`, body))),
81
+ run: async (v) => normalizeRun(unwrap(await http.get(`${base}/runs/${id(v)}`))),
82
+ runPlan: async (v, query) => normalizePlan(unwrap(await http.get(`${base}/runs/${id(v)}/plan${planQuery(query)}`))),
83
+ runs: async (limit = 30) => nz(unwrap(await http.get(`${base}/runs?limit=${limit}`))).map(normalizeRun),
84
+ cancel: async (v) => normalizeRun(unwrap(await http.post(`${base}/runs/${id(v)}/cancel`))),
85
+ mediaStatus: async (runId) => normalizeStatus(unwrap(await http.get(`${base}/media/status${q(runId)}`))),
86
+ mediaManifest: async () => nz(unwrap(await http.get(`${base}/media/manifest`))),
87
+ mediaVerify: async () => {
88
+ const r = unwrap(await http.post(`${base}/media/verify`));
89
+ return { ...r, missing: nz(r.missing), corrupt: nz(r.corrupt) };
90
+ },
91
+ mediaRetry: async (runId) => unwrap(await http.post(`${base}/media/retry`, runId ? { run_id: runId } : {})).requeued,
92
+ reviews: async (f) => {
93
+ const page = unwrap(await http.get(`${base}/reviews${reviewQuery(f)}`));
94
+ return { items: nz(page?.items).map(normalizeReview), counts: page?.counts ?? {}, ...(page?.next ? { next: page.next } : {}) };
95
+ },
96
+ decideReviews: async (decisions) => nz(unwrap(await http.post(`${base}/reviews/decide`, { decisions }))).map(normalizeReview),
97
+ applyApproved: async (entity) => normalizeRun(unwrap(await http.post(`${base}/reviews/apply`, { entity }))),
98
+ createUpload: async (body) => normalizeUpload(unwrap(await http.post(`${base}/uploads`, body))),
99
+ upload: async (v) => normalizeUpload(unwrap(await http.get(`${base}/uploads/${id(v)}`))),
100
+ uploadPart: async (v, index, chunk, o = {}) => {
101
+ const headers = { 'Content-Type': 'application/octet-stream' };
102
+ if (o.sha256)
103
+ headers['X-Content-Sha256'] = o.sha256;
104
+ await http.post(`${base}/uploads/${id(v)}/parts/${index}`, chunk, { headers, ...(o.signal ? { signal: o.signal } : {}) });
105
+ },
106
+ completeUpload: async (v, o = {}) => normalizeUpload(unwrap(await http.post(`${base}/uploads/${id(v)}/complete`, o.sha256 ? { sha256: o.sha256 } : {}))),
107
+ abortUpload: async (v) => {
108
+ await http.post(`${base}/uploads/${id(v)}/abort`);
109
+ },
110
+ };
111
+ }
112
+ /** Extracts the server message from an axios-like error. */
113
+ export function apiErrorMessage(err, fallback) {
114
+ const e = err;
115
+ return e?.response?.data?.message || fallback;
116
+ }
117
+ /** HTTP status of an axios-like error, if any. */
118
+ export function apiErrorStatus(err) {
119
+ return err?.response?.status;
120
+ }
121
+ /**
122
+ * The plan the person reviewed is no longer the one the server would apply (409 on
123
+ * execute with `expectPlanHash`): simulate again before applying.
124
+ */
125
+ export function isPlanChanged(err) {
126
+ return apiErrorStatus(err) === 409 && /plan/i.test(apiErrorMessage(err, ''));
127
+ }
128
+ /** Every page of the review queue (follows `next`), up to `max` rows. */
129
+ export async function listAllReviews(api, filter = {}, max = 5000) {
130
+ const items = [];
131
+ let page = await api.reviews({ limit: 500, ...filter });
132
+ const counts = page.counts;
133
+ for (;;) {
134
+ items.push(...page.items);
135
+ if (!page.next || items.length >= max)
136
+ break;
137
+ page = await api.reviews({ limit: 500, ...filter, cursor: page.next });
138
+ }
139
+ return { items: items.slice(0, max), counts, ...(page.next && items.length >= max ? { next: page.next } : {}) };
140
+ }
141
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAyBnC,MAAM,MAAM,GAAG,CAAI,GAAuB,EAAK,EAAE,CAAE,GAAG,CAAC,IAAoB,CAAC,IAAI,CAAA;AAEhF,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,CAAoE;IAC7F,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;AAC3E,CAAC;AAiDD,MAAM,EAAE,GAAG,CAAI,CAAyB,EAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;AAEzD,qEA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E,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;AACjH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * What the current person may do, as decided by the host (from its roles or
3
+ * permissions). The UI only hides or disables controls: the server must still
4
+ * enforce every rule, this is not a security boundary.
5
+ */
6
+ export interface DataloadCapabilities {
7
+ /** Apply a load (dry-run is read-only and is always offered). */
8
+ launch: boolean;
9
+ /** Cancel a run in flight. */
10
+ cancel: boolean;
11
+ /** Approve or reject rows in the review queue, and apply the approved ones. */
12
+ approve: boolean;
13
+ /** Requeue media that could not be backed up. */
14
+ retryMedia: boolean;
15
+ /** Re-read every backed-up original and compare its sha256. */
16
+ verifyMedia: boolean;
17
+ /** Edit and save an organization's overrides. */
18
+ editOverrides: boolean;
19
+ }
20
+ export declare const ALL_CAPABILITIES: DataloadCapabilities;
21
+ /**
22
+ * Without `capabilities` the UI offers everything (the server decides). Once the
23
+ * host passes an object, anything it leaves out is denied: a new capability added
24
+ * to the SDK never appears enabled by accident.
25
+ */
26
+ export declare function resolveCapabilities(c?: Partial<DataloadCapabilities>): DataloadCapabilities;
27
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,MAAM,EAAE,OAAO,CAAA;IACf,8BAA8B;IAC9B,MAAM,EAAE,OAAO,CAAA;IACf,+EAA+E;IAC/E,OAAO,EAAE,OAAO,CAAA;IAChB,iDAAiD;IACjD,UAAU,EAAE,OAAO,CAAA;IACnB,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAA;IACpB,iDAAiD;IACjD,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,oBAO9B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAU3F"}
@@ -0,0 +1,26 @@
1
+ export const ALL_CAPABILITIES = {
2
+ launch: true,
3
+ cancel: true,
4
+ approve: true,
5
+ retryMedia: true,
6
+ verifyMedia: true,
7
+ editOverrides: true,
8
+ };
9
+ /**
10
+ * Without `capabilities` the UI offers everything (the server decides). Once the
11
+ * host passes an object, anything it leaves out is denied: a new capability added
12
+ * to the SDK never appears enabled by accident.
13
+ */
14
+ export function resolveCapabilities(c) {
15
+ if (!c)
16
+ return ALL_CAPABILITIES;
17
+ return {
18
+ launch: !!c.launch,
19
+ cancel: !!c.cancel,
20
+ approve: !!c.approve,
21
+ retryMedia: !!c.retryMedia,
22
+ verifyMedia: !!c.verifyMedia,
23
+ editOverrides: !!c.editOverrides,
24
+ };
25
+ }
26
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,gBAAgB,GAAyB;IACpD,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,IAAI;CACpB,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAiC;IACnE,IAAI,CAAC,CAAC;QAAE,OAAO,gBAAgB,CAAA;IAC/B,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;QAClB,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;QAClB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QACpB,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU;QAC1B,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW;QAC5B,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa;KACjC,CAAA;AACH,CAAC"}