sheet-to-schema 1.0.0-rc.2 → 1.0.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/LICENSE +21 -0
- package/README.md +14 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.d.mts +40 -14
- package/dist/node/index.d.ts +40 -14
- package/dist/node/index.js +32 -3
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs.map +1 -1
- package/package.json +17 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nizamudeen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ one record per row, or per group of rows, reporting every cell it could not use.
|
|
|
12
12
|
- **The same engine on both sides.** A file imports to the same records in the browser and
|
|
13
13
|
on the server, because both run the same function over the same plan.
|
|
14
14
|
|
|
15
|
-
> **Status:
|
|
15
|
+
> **Status: stable (1.0.0).** It is the import engine of
|
|
16
16
|
> [Dynamic Entity](https://github.com/berserker5619/Dynamic-Entity#readme) 3.0, extracted so it can be used without it.
|
|
17
17
|
> Members marked `@internal` are not covered by semver and may change in any release.
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@ npm install busboy # to receive uploads
|
|
|
26
26
|
npm install express # for the ready-made router
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Node
|
|
29
|
+
Node 20 or later for the main entry; the three packages above are optional peers, loaded the
|
|
30
30
|
first time they are needed. Reading a CSV needs none of them.
|
|
31
31
|
|
|
32
32
|
## Quick start
|
|
@@ -188,6 +188,18 @@ app.use(
|
|
|
188
188
|
Without Express, call `runImport`, `previewSheet`, `writeTemplate` and `receiveUpload`
|
|
189
189
|
yourself; the router is a few lines over them.
|
|
190
190
|
|
|
191
|
+
The typings need nothing from `@types/express`: the router, request and response are typed by
|
|
192
|
+
what the router uses (`ImportRouter`, `ImportRequest`, `ImportResponse`), and an Express 4 or 5
|
|
193
|
+
router fits them. A callback that needs more of the request annotates it, and the options take
|
|
194
|
+
that type:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
createImportRouter(express.Router(), {
|
|
198
|
+
bindings: (name, request: express.Request & { tenant: string }) => loadBinding(request.tenant, name),
|
|
199
|
+
onImport: async (records, { request }) => saveAll(request.tenant, records), // request is typed the same
|
|
200
|
+
});
|
|
201
|
+
```
|
|
202
|
+
|
|
191
203
|
Four things to know before deploying it:
|
|
192
204
|
|
|
193
205
|
1. **An import is not transactional.** A file that fails at row 30,000 has written 29,999
|
package/dist/index.d.mts
CHANGED
|
@@ -706,7 +706,7 @@ declare function exampleJsonAdapter(sample: unknown, options?: ExampleJsonAdapte
|
|
|
706
706
|
/**
|
|
707
707
|
* csv.ts — RFC 4180 parse and emit, with no dependency.
|
|
708
708
|
*
|
|
709
|
-
* Moved from Dynamic Entity's `@dynamic-entity/core`, which re-exports it (docs/phase2-plan.md).
|
|
709
|
+
* Moved from Dynamic Entity's `@dynamic-entity/core`, which re-exports it (https://github.com/berserker5619/Dynamic-Entity/blob/main/docs/phase2-plan.md).
|
|
710
710
|
*
|
|
711
711
|
* Why this is here rather than left to the consumer: a spreadsheet import that needs a
|
|
712
712
|
* parser installed before it does anything is a feature with a prerequisite. CSV is the
|
|
@@ -967,7 +967,7 @@ interface ImportErrorResponse {
|
|
|
967
967
|
* A client compares it with its own at major.minor, to notice that the two halves of an import
|
|
968
968
|
* have moved apart. `version.spec.ts` holds it equal to `package.json`.
|
|
969
969
|
*/
|
|
970
|
-
declare const IMPORTER_VERSION = "1.0.0
|
|
970
|
+
declare const IMPORTER_VERSION = "1.0.0";
|
|
971
971
|
/** The plan versions this package reads: v1, with no `planVersion`, and v2. */
|
|
972
972
|
declare const PLAN_VERSIONS: readonly number[];
|
|
973
973
|
|
package/dist/index.d.ts
CHANGED
|
@@ -706,7 +706,7 @@ declare function exampleJsonAdapter(sample: unknown, options?: ExampleJsonAdapte
|
|
|
706
706
|
/**
|
|
707
707
|
* csv.ts — RFC 4180 parse and emit, with no dependency.
|
|
708
708
|
*
|
|
709
|
-
* Moved from Dynamic Entity's `@dynamic-entity/core`, which re-exports it (docs/phase2-plan.md).
|
|
709
|
+
* Moved from Dynamic Entity's `@dynamic-entity/core`, which re-exports it (https://github.com/berserker5619/Dynamic-Entity/blob/main/docs/phase2-plan.md).
|
|
710
710
|
*
|
|
711
711
|
* Why this is here rather than left to the consumer: a spreadsheet import that needs a
|
|
712
712
|
* parser installed before it does anything is a feature with a prerequisite. CSV is the
|
|
@@ -967,7 +967,7 @@ interface ImportErrorResponse {
|
|
|
967
967
|
* A client compares it with its own at major.minor, to notice that the two halves of an import
|
|
968
968
|
* have moved apart. `version.spec.ts` holds it equal to `package.json`.
|
|
969
969
|
*/
|
|
970
|
-
declare const IMPORTER_VERSION = "1.0.0
|
|
970
|
+
declare const IMPORTER_VERSION = "1.0.0";
|
|
971
971
|
/** The plan versions this package reads: v1, with no `planVersion`, and v2. */
|
|
972
972
|
declare const PLAN_VERSIONS: readonly number[];
|
|
973
973
|
|
package/dist/index.js
CHANGED
|
@@ -1199,7 +1199,7 @@ function suggestMapping(headers, adapter, options = {}) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
|
|
1201
1201
|
// src/version.ts
|
|
1202
|
-
var IMPORTER_VERSION = "1.0.0
|
|
1202
|
+
var IMPORTER_VERSION = "1.0.0";
|
|
1203
1203
|
var PLAN_VERSIONS = [1, 2];
|
|
1204
1204
|
|
|
1205
1205
|
// src/json-schema-adapter.ts
|