@krizaka/storage 0.0.0-stage → 0.3.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 +201 -0
- package/README.md +25 -2
- package/dist/chunk-C3LEYKGC.js +149 -0
- package/dist/chunk-C3LEYKGC.js.map +1 -0
- package/dist/chunk-W56662PQ.js +346 -0
- package/dist/chunk-W56662PQ.js.map +1 -0
- package/dist/chunk-ZWQMALDF.js +81 -0
- package/dist/chunk-ZWQMALDF.js.map +1 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +1 -0
- package/dist/port-6VXXuSbc.d.ts +65 -0
- package/dist/resolve.d.ts +74 -0
- package/dist/resolve.js +52 -0
- package/dist/resolve.js.map +1 -0
- package/dist/settings.d.ts +68 -0
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -0
- package/dist/storage-DurtrQKq.d.ts +73 -0
- package/dist/testkit.d.ts +6 -0
- package/dist/testkit.js +44 -0
- package/dist/testkit.js.map +1 -0
- package/dist/where-DKtS1O5l.d.ts +71 -0
- package/package.json +86 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The country of each provider region (data: a new region is a line here, one table for every product, ADR-010). A region not listed
|
|
3
|
+
* is unknown: nothing claims a country for it, and the generated residency text never says « Canada » for it.
|
|
4
|
+
*/
|
|
5
|
+
declare const COUNTRY_OF_REGION: Readonly<Record<string, string>>;
|
|
6
|
+
type Residency = "canada" | "elsewhere";
|
|
7
|
+
/** The ISO country of a provider region, or undefined when the region is not mapped. */
|
|
8
|
+
declare const countryOf: (region: string) => string | undefined;
|
|
9
|
+
/** Canada only when the table says so; an unmapped region is « elsewhere », never a guess in Canada's favour. */
|
|
10
|
+
declare const residencyOf: (region: string) => Residency;
|
|
11
|
+
/**
|
|
12
|
+
* Residency of a configured store: the region AND the endpoint have to agree. A host that names a known region
|
|
13
|
+
* (`nyc3.digitaloceanspaces.com`, `ny.storage.bunnycdn.com`) in another country than the region setting is the contradiction that
|
|
14
|
+
* would let a text claim Canada falsely, so any known region label of the host that is not Canadian makes the answer « elsewhere ».
|
|
15
|
+
* A Bunny-shaped zone (`http`) has no Canadian region, so it is never « canada ».
|
|
16
|
+
*/
|
|
17
|
+
declare function residencyOfConfig(config: {
|
|
18
|
+
provider: "http" | "s3";
|
|
19
|
+
endpoint: string;
|
|
20
|
+
region: string;
|
|
21
|
+
}): Residency;
|
|
22
|
+
|
|
23
|
+
/** The two kinds every product shares; the others are the product's. */
|
|
24
|
+
declare const STORE_KIND: {
|
|
25
|
+
readonly none: "none";
|
|
26
|
+
readonly device: "device";
|
|
27
|
+
};
|
|
28
|
+
/** Whose store it is: Krizaka's (the deployment's), the workspace's own, or the person's device. */
|
|
29
|
+
type StoreOwner = "krizaka" | "workspace" | "device";
|
|
30
|
+
/** Where objects live, as the product says it: computed from the configuration, never typed. */
|
|
31
|
+
interface StoreDescriptor {
|
|
32
|
+
/** The product's name for the store (`s3`, `bunny`, `database`, `none`, `device`…). */
|
|
33
|
+
kind: string;
|
|
34
|
+
endpoint: string | null;
|
|
35
|
+
region: string | null;
|
|
36
|
+
residency: Residency | "unknown" | "device";
|
|
37
|
+
encrypted: boolean;
|
|
38
|
+
owner: StoreOwner;
|
|
39
|
+
/** For fictional and development data only: the notice says so instead of claiming a place. */
|
|
40
|
+
devOnly: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** The descriptor of a configured store, from its configuration alone (see `residencyOfConfig`: a Bunny-shaped zone is dev only and never Canadian). */
|
|
43
|
+
declare function describeStore(config: {
|
|
44
|
+
provider: "http" | "s3";
|
|
45
|
+
endpoint: string;
|
|
46
|
+
region: string;
|
|
47
|
+
}, options: {
|
|
48
|
+
encrypted: boolean;
|
|
49
|
+
owner?: StoreOwner;
|
|
50
|
+
httpKind?: string;
|
|
51
|
+
}): StoreDescriptor;
|
|
52
|
+
interface WhereOptions {
|
|
53
|
+
/** Stores that are not configurable but fixed places (Yomizaka's managed database in Toronto), by kind. */
|
|
54
|
+
fixed?: Readonly<Record<string, StoreDescriptor>>;
|
|
55
|
+
/** Kinds that exist only for development data. */
|
|
56
|
+
devOnly?: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Where an object lives, from the store kind recorded with it and the store configured now. True at every moment, per object:
|
|
60
|
+
* a fixed place says what it is; `none` and `device` say so; the active store answers for its own kind; any other kind (a store
|
|
61
|
+
* no longer configured) says only its kind, with an unknown residency, so nothing is claimed that nothing proves.
|
|
62
|
+
*/
|
|
63
|
+
declare function where(kind: string, active: StoreDescriptor, options?: WhereOptions): StoreDescriptor;
|
|
64
|
+
type NoticeKey = "none" | "krizakaCanadaEncrypted" | "krizakaCanada" | "krizakaElsewhere" | "workspace" | "devOnly" | "device";
|
|
65
|
+
/** Which sentence says where this object lives (« Not kept », « Kept: Krizaka (Canada, encrypted) »…), with its variables; the product's messages hold the words. */
|
|
66
|
+
declare function storageNotice(d: StoreDescriptor): {
|
|
67
|
+
key: NoticeKey;
|
|
68
|
+
vars: Record<string, string>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { COUNTRY_OF_REGION as C, type NoticeKey as N, type Residency as R, STORE_KIND as S, type WhereOptions as W, type StoreDescriptor as a, type StoreOwner as b, countryOf as c, describeStore as d, residencyOfConfig as e, residencyOf as r, storageNotice as s, where as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krizaka/storage",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Files behind one port for every Krizaka product: put with a content-hashed name, get, head, delete, list, signed and public URLs; adapters over an injected fetch for an HTTP object store and any S3-compatible bucket (Signature V4, no SDK), and a local folder; layout as data, bytes checked by magic number, limits passed in. The admin chooses the provider through settings.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"krizaka",
|
|
7
|
+
"storage",
|
|
8
|
+
"files",
|
|
9
|
+
"s3",
|
|
10
|
+
"http",
|
|
11
|
+
"cdn",
|
|
12
|
+
"upload"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/krizaka/krizaka-ts/tree/main/packages/storage",
|
|
15
|
+
"bugs": "https://github.com/krizaka/krizaka-ts/issues",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/krizaka/krizaka-ts.git",
|
|
19
|
+
"directory": "packages/storage"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"author": "Krizaka (https://www.krizaka.com)",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./settings": {
|
|
33
|
+
"types": "./dist/settings.d.ts",
|
|
34
|
+
"import": "./dist/settings.js"
|
|
35
|
+
},
|
|
36
|
+
"./resolve": {
|
|
37
|
+
"types": "./dist/resolve.d.ts",
|
|
38
|
+
"import": "./dist/resolve.js"
|
|
39
|
+
},
|
|
40
|
+
"./testkit": {
|
|
41
|
+
"types": "./dist/testkit.d.ts",
|
|
42
|
+
"import": "./dist/testkit.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"README.md",
|
|
49
|
+
"LICENSE"
|
|
50
|
+
],
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=22"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.10.0",
|
|
57
|
+
"@types/pg": "^8.23.1",
|
|
58
|
+
"eslint": "^9.39.0",
|
|
59
|
+
"pg": "^8.23.1",
|
|
60
|
+
"tsup": "^8.5.0",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vitest": "^4.1.11",
|
|
63
|
+
"zod": "^4.6.7",
|
|
64
|
+
"@krizaka/config": "^0.9.1"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@krizaka/settings": "^0.5.0",
|
|
68
|
+
"@krizaka/db": "^0.2.0"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"vitest": ">=4",
|
|
72
|
+
"zod": ">=3.23"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"vitest": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"zod": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
|
|
84
|
+
"lint": "eslint . --max-warnings 0 && tsc --noEmit",
|
|
85
|
+
"typecheck": "tsc --noEmit",
|
|
86
|
+
"test": "vitest run",
|
|
87
|
+
"check": "pnpm run lint && pnpm run test && pnpm run build"
|
|
88
|
+
}
|
|
6
89
|
}
|