nuxt-files-sdk 0.0.5 → 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.
- package/LICENSE +1 -1
- package/README.md +35 -9
- package/dist/config/load.js +67 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/merge.d.ts +5 -0
- package/dist/config/merge.js +22 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/prune.js +55 -0
- package/dist/config/prune.js.map +1 -0
- package/dist/config.d.ts +101 -103
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/devtools/auth.js +49 -0
- package/dist/devtools/auth.js.map +1 -0
- package/dist/devtools/client/app.js +6 -4
- package/dist/devtools/client/browser-agent-rpc-BXhoSh1z-DRoP5jHQ.js +1 -0
- package/dist/devtools/client/index.html +4 -1
- package/dist/devtools/devframe.js +7 -1
- package/dist/devtools/devframe.js.map +1 -1
- package/dist/devtools/diagnostics.d.ts +1 -1
- package/dist/devtools/diagnostics.js +1 -1
- package/dist/devtools/diagnostics.js.map +1 -1
- package/dist/devtools/files-read.d.ts +1 -1
- package/dist/devtools/files-write.d.ts +1 -1
- package/dist/devtools/files.js +7 -4
- package/dist/devtools/files.js.map +1 -1
- package/dist/devtools/index.js +24 -6
- package/dist/devtools/index.js.map +1 -1
- package/dist/devtools/nuxt-v3-handler.js +1 -1
- package/dist/devtools/nuxt-v3-handler.js.map +1 -1
- package/dist/devtools/nuxt-v3.js +1 -1
- package/dist/devtools/nuxt-v3.js.map +1 -1
- package/dist/devtools/nuxt-v4.js.map +1 -1
- package/dist/devtools/snapshot.d.ts +8 -2
- package/dist/devtools/snapshot.js +13 -3
- package/dist/devtools/snapshot.js.map +1 -1
- package/dist/devtools/token.d.ts +14 -0
- package/dist/devtools/token.js +17 -0
- package/dist/devtools/token.js.map +1 -0
- package/dist/integration/nitro.d.ts +6 -0
- package/dist/integration/nitro.js +160 -63
- package/dist/integration/nitro.js.map +1 -1
- package/dist/module.d.ts +1 -4
- package/dist/module.js +31 -20
- package/dist/module.js.map +1 -1
- package/dist/nitro.d.ts +2 -4
- package/dist/nitro.js +2 -4
- package/dist/nitro.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/runtime/internal.d.ts +11 -0
- package/dist/runtime/internal.js +30 -0
- package/dist/runtime/internal.js.map +1 -0
- package/dist/runtime/normalize.js +29 -0
- package/dist/runtime/normalize.js.map +1 -0
- package/dist/runtime/provider-types.d.ts +53 -0
- package/dist/runtime/registry.d.ts +55 -8
- package/dist/runtime/registry.js +125 -89
- package/dist/runtime/registry.js.map +1 -1
- package/dist/runtime.d.ts +8 -9
- package/dist/runtime.js +8 -25
- package/dist/runtime.js.map +1 -1
- package/package.json +25 -14
package/dist/runtime/registry.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getProvider, listEnvVars } from "files-sdk/providers";
|
|
1
|
+
import { normalizeFilesConfig } from "./normalize.js";
|
|
3
2
|
import { createFiles } from "files-sdk";
|
|
4
3
|
//#region src/runtime/registry.ts
|
|
5
4
|
const runHooks = async (...hooks) => {
|
|
@@ -7,143 +6,180 @@ const runHooks = async (...hooks) => {
|
|
|
7
6
|
await hook();
|
|
8
7
|
} catch {}
|
|
9
8
|
};
|
|
10
|
-
const
|
|
11
|
-
const isStorageRecord = (value) => Boolean(value && typeof value === "object" && Object.values(value).every(isStorageConfig));
|
|
9
|
+
const nativeFilesOptions = ({ adapter: _adapter, config: _config, hooks: _hooks, plugins: _plugins, ...options }) => options;
|
|
12
10
|
/** Lazily construct and memoize native Files clients for a validated project configuration. */
|
|
13
11
|
var FilesRegistry = class {
|
|
14
|
-
#
|
|
15
|
-
#
|
|
12
|
+
#entries;
|
|
13
|
+
#environment;
|
|
16
14
|
#factories;
|
|
17
15
|
#hooks;
|
|
16
|
+
#adapters = /* @__PURE__ */ new Map();
|
|
17
|
+
#adapterInitializing = /* @__PURE__ */ new Set();
|
|
18
18
|
#instances = /* @__PURE__ */ new Map();
|
|
19
|
-
#
|
|
19
|
+
#filesInitializing = /* @__PURE__ */ new Set();
|
|
20
|
+
#pluginNames = /* @__PURE__ */ new Map();
|
|
20
21
|
#diagnostics = /* @__PURE__ */ new Map();
|
|
21
22
|
/** Create a registry without constructing a provider. */
|
|
22
23
|
constructor(config, options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (config.storage && !isStorageConfig(config.storage) && (!isStorageRecord(config.storage) || Object.keys(config.storage).length === 0)) throw new Error("[nuxt-files-sdk:invalid-config] At least one storage is required.");
|
|
27
|
-
if (!config.storage && !isStorageConfig(config.devStorage)) {
|
|
28
|
-
if (!isStorageRecord(config.devStorage) || Object.keys(config.devStorage).length === 0) throw new Error("[nuxt-files-sdk:invalid-config] At least one development storage is required.");
|
|
29
|
-
} else if (config.storage && !isStorageConfig(config.storage)) {
|
|
30
|
-
if (config.devStorage && !isStorageRecord(config.devStorage)) throw new Error("[nuxt-files-sdk:invalid-config] Named storage requires named devStorage overrides.");
|
|
31
|
-
for (const name of Object.keys(config.devStorage ?? {})) if (!Object.hasOwn(config.storage, name)) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${name}".`);
|
|
32
|
-
}
|
|
33
|
-
this.#config = config;
|
|
34
|
-
this.#development = development;
|
|
24
|
+
this.#entries = normalizeFilesConfig(config);
|
|
25
|
+
if (!this.#entries.size) throw new Error("[nuxt-files-sdk:invalid-config] At least one storage is required.");
|
|
26
|
+
this.#environment = options.environment ?? {};
|
|
35
27
|
this.#factories = options.factories;
|
|
36
28
|
this.#hooks = options.hooks ?? {};
|
|
37
29
|
}
|
|
38
|
-
get(
|
|
30
|
+
get(...args) {
|
|
31
|
+
const name = args[0];
|
|
39
32
|
const entry = this.#entry(name);
|
|
40
|
-
const key = entry.name
|
|
33
|
+
const key = entry.name;
|
|
41
34
|
const cached = this.#instances.get(key);
|
|
42
35
|
if (cached) return cached;
|
|
43
|
-
if (this.#
|
|
44
|
-
this.#
|
|
36
|
+
if (this.#filesInitializing.has(key)) throw this.#circular(key);
|
|
37
|
+
this.#filesInitializing.add(key);
|
|
45
38
|
try {
|
|
46
39
|
const files = this.#create(entry);
|
|
47
40
|
this.#instances.set(key, files);
|
|
48
41
|
this.#diagnostics.delete(key);
|
|
49
42
|
return files;
|
|
50
43
|
} catch (error) {
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
this.#diagnostics.set(key, {
|
|
45
|
+
code: "NUXT_FILES_ADAPTER_INIT_FAILED",
|
|
46
|
+
...entry.name === void 0 ? {} : { name: entry.name },
|
|
47
|
+
adapter: typeof entry.storage.adapter === "string" ? entry.storage.adapter : "custom"
|
|
48
|
+
});
|
|
53
49
|
throw error;
|
|
54
50
|
} finally {
|
|
55
|
-
this.#
|
|
51
|
+
this.#filesInitializing.delete(key);
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
/** Return secret-free storage metadata and initialization state for development diagnostics. */
|
|
59
55
|
inspect() {
|
|
60
56
|
return {
|
|
61
|
-
storages: this.#entries().map(({ name, storage
|
|
57
|
+
storages: [...this.#entries.values()].map(({ name, storage }) => ({
|
|
62
58
|
...name === void 0 ? {} : { name },
|
|
63
|
-
adapter:
|
|
64
|
-
plugins: storage.plugins
|
|
65
|
-
|
|
66
|
-
initialized: this.#instances.has(name ?? "")
|
|
59
|
+
adapter: typeof storage.adapter === "string" ? storage.adapter : "custom",
|
|
60
|
+
plugins: this.#pluginNames.get(name) ?? (Array.isArray(storage.plugins) ? storage.plugins.map((plugin) => plugin.name) : []),
|
|
61
|
+
initialized: this.#instances.has(name)
|
|
67
62
|
})),
|
|
68
63
|
diagnostics: [...this.#diagnostics.values()]
|
|
69
64
|
};
|
|
70
65
|
}
|
|
71
|
-
#entries() {
|
|
72
|
-
const storage = this.#config.storage;
|
|
73
|
-
const devStorage = this.#config.devStorage;
|
|
74
|
-
if (!storage) {
|
|
75
|
-
if (isStorageConfig(devStorage)) return [{
|
|
76
|
-
name: void 0,
|
|
77
|
-
storage: devStorage,
|
|
78
|
-
override: void 0,
|
|
79
|
-
source: "devStorage"
|
|
80
|
-
}];
|
|
81
|
-
return Object.entries(devStorage ?? {}).map(([name, developmentStorage]) => ({
|
|
82
|
-
name,
|
|
83
|
-
storage: developmentStorage,
|
|
84
|
-
override: void 0,
|
|
85
|
-
source: "devStorage"
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
if (isStorageConfig(storage)) {
|
|
89
|
-
const override = this.#development && isStorageConfig(devStorage) ? devStorage : void 0;
|
|
90
|
-
return [{
|
|
91
|
-
name: void 0,
|
|
92
|
-
storage,
|
|
93
|
-
override,
|
|
94
|
-
source: override ? "devStorage" : "storage"
|
|
95
|
-
}];
|
|
96
|
-
}
|
|
97
|
-
const overrides = this.#development && isStorageRecord(devStorage) ? devStorage : void 0;
|
|
98
|
-
return Object.entries(storage).map(([name, namedStorage]) => ({
|
|
99
|
-
name,
|
|
100
|
-
storage: namedStorage,
|
|
101
|
-
override: overrides?.[name],
|
|
102
|
-
source: overrides?.[name] ? "devStorage" : "storage"
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
66
|
#entry(name) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (name !== void 0) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${name}".`);
|
|
109
|
-
return entries[0];
|
|
110
|
-
}
|
|
111
|
-
if (name === void 0) throw new Error("[nuxt-files-sdk:storage-name-required] A storage name is required.");
|
|
112
|
-
const entry = entries.find((candidate) => candidate.name === name);
|
|
67
|
+
if (name === void 0 && !this.#entries.has(void 0)) throw new Error("[nuxt-files-sdk:storage-name-required] A storage name is required.");
|
|
68
|
+
const entry = this.#entries.get(name);
|
|
113
69
|
if (!entry) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${name}".`);
|
|
114
70
|
return entry;
|
|
115
71
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
const
|
|
72
|
+
/** Resolve one selected adapter without constructing its Files client. */
|
|
73
|
+
resolveAdapter(name) {
|
|
74
|
+
const entry = this.#entry(name);
|
|
75
|
+
const key = entry.name;
|
|
76
|
+
const cached = this.#adapters.get(key);
|
|
77
|
+
if (cached) return cached;
|
|
78
|
+
if (this.#adapterInitializing.has(key)) throw this.#circular(key);
|
|
79
|
+
this.#adapterInitializing.add(key);
|
|
80
|
+
try {
|
|
81
|
+
const adapter = this.#createAdapter(entry);
|
|
82
|
+
this.#adapters.set(key, adapter);
|
|
83
|
+
return adapter;
|
|
84
|
+
} finally {
|
|
85
|
+
this.#adapterInitializing.delete(key);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
#circular(name) {
|
|
89
|
+
return /* @__PURE__ */ new Error(`[nuxt-files-sdk:circular-initialization] Circular storage dependency${name ? ` at "${name}"` : ""}.`);
|
|
90
|
+
}
|
|
91
|
+
#createAdapter({ storage: selected }) {
|
|
92
|
+
const factory = typeof selected.adapter === "string" ? this.#factories[selected.adapter] : selected.adapter;
|
|
93
|
+
if (!factory) throw new Error(`[nuxt-files-sdk:adapter-not-generated] Adapter "${typeof selected.adapter === "string" ? selected.adapter : "custom"}" is not available in this build.`);
|
|
94
|
+
const environment = typeof selected.adapter === "string" ? this.#environment[selected.adapter] ?? [] : [];
|
|
95
|
+
return withNuxtEnvironment(environment, () => {
|
|
121
96
|
const input = typeof selected.config === "function" ? selected.config() : selected.config;
|
|
122
97
|
if (input && typeof input === "object" && "then" in input) throw new Error("[nuxt-files-sdk:async-config] Storage config functions must be synchronous.");
|
|
123
|
-
|
|
98
|
+
const value = selected.adapter === "s3" ? withS3NuxtCredentials(input) : selected.adapter === "bun-s3" ? withBunS3NuxtOptions(input) : input;
|
|
99
|
+
return factory(value);
|
|
124
100
|
});
|
|
125
|
-
|
|
101
|
+
}
|
|
102
|
+
#create({ name, storage }) {
|
|
103
|
+
const adapter = this.resolveAdapter(name);
|
|
104
|
+
const plugins = typeof storage.plugins === "function" ? storage.plugins({ storage: (storageName) => this.resolveAdapter(storageName) }) : storage.plugins;
|
|
105
|
+
const files = createFiles({
|
|
126
106
|
adapter,
|
|
107
|
+
...nativeFilesOptions(storage),
|
|
127
108
|
hooks: {
|
|
128
109
|
onAction: (event) => runHooks(() => storage.hooks?.onAction?.(event), () => this.#hooks.onAction?.(event, name)),
|
|
129
110
|
onError: (event) => runHooks(() => storage.hooks?.onError?.(event), () => this.#hooks.onError?.(event, name)),
|
|
130
111
|
onRetry: (event) => runHooks(() => storage.hooks?.onRetry?.(event), () => this.#hooks.onRetry?.(event, name))
|
|
131
112
|
},
|
|
132
|
-
...
|
|
133
|
-
...storage.prefix === void 0 ? {} : { prefix: storage.prefix },
|
|
134
|
-
...storage.retries === void 0 ? {} : { retries: storage.retries },
|
|
135
|
-
...storage.timeout === void 0 ? {} : { timeout: storage.timeout }
|
|
113
|
+
...plugins ? { plugins } : {}
|
|
136
114
|
});
|
|
115
|
+
if (plugins) this.#pluginNames.set(name, plugins.map((plugin) => plugin.name));
|
|
116
|
+
return files;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
/** Pass NUXT_ credentials explicitly because the AWS SDK resolves its chain after construction. */
|
|
120
|
+
const withS3NuxtCredentials = (input) => {
|
|
121
|
+
if (!input || typeof input !== "object" || "credentials" in input) return input;
|
|
122
|
+
if ([
|
|
123
|
+
"AWS_ACCESS_KEY_ID",
|
|
124
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
125
|
+
"AWS_PROFILE",
|
|
126
|
+
"AWS_WEB_IDENTITY_TOKEN_FILE",
|
|
127
|
+
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",
|
|
128
|
+
"AWS_CONTAINER_CREDENTIALS_FULL_URI"
|
|
129
|
+
].some((key) => process.env[key] !== void 0)) return input;
|
|
130
|
+
const accessKeyId = process.env.NUXT_AWS_ACCESS_KEY_ID;
|
|
131
|
+
const secretAccessKey = process.env.NUXT_AWS_SECRET_ACCESS_KEY;
|
|
132
|
+
if (!accessKeyId || !secretAccessKey) return input;
|
|
133
|
+
return {
|
|
134
|
+
...input,
|
|
135
|
+
credentials: {
|
|
136
|
+
accessKeyId,
|
|
137
|
+
secretAccessKey,
|
|
138
|
+
...(process.env.AWS_SESSION_TOKEN ?? process.env.NUXT_AWS_SESSION_TOKEN) && { sessionToken: process.env.AWS_SESSION_TOKEN ?? process.env.NUXT_AWS_SESSION_TOKEN }
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/** Bun resolves these environment keys in its own client; pass NUXT_ aliases as explicit options. */
|
|
143
|
+
const withBunS3NuxtOptions = (input) => {
|
|
144
|
+
if (input && (typeof input !== "object" || "client" in input)) return input;
|
|
145
|
+
const options = { ...typeof input === "object" && input ? input : {} };
|
|
146
|
+
for (const [field, key, alias] of [
|
|
147
|
+
[
|
|
148
|
+
"accessKeyId",
|
|
149
|
+
"AWS_ACCESS_KEY_ID",
|
|
150
|
+
"S3_ACCESS_KEY_ID"
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
"secretAccessKey",
|
|
154
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
155
|
+
"S3_SECRET_ACCESS_KEY"
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
"sessionToken",
|
|
159
|
+
"AWS_SESSION_TOKEN",
|
|
160
|
+
"S3_SESSION_TOKEN"
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
"region",
|
|
164
|
+
"AWS_REGION",
|
|
165
|
+
"S3_REGION"
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
"bucket",
|
|
169
|
+
"AWS_BUCKET",
|
|
170
|
+
"S3_BUCKET"
|
|
171
|
+
]
|
|
172
|
+
]) {
|
|
173
|
+
if (Object.hasOwn(options, field) || process.env[key] !== void 0 || process.env[alias] !== void 0) continue;
|
|
174
|
+
const value = process.env[`NUXT_${key}`] ?? process.env[`NUXT_${alias}`];
|
|
175
|
+
if (value !== void 0) options[field] = value;
|
|
137
176
|
}
|
|
177
|
+
return options;
|
|
138
178
|
};
|
|
139
179
|
/** Bridge only NUXT_ aliases declared by the configured native provider during synchronous construction. */
|
|
140
|
-
const withNuxtEnvironment = (
|
|
141
|
-
if (!getProvider(provider)) return load();
|
|
142
|
-
const variables = listEnvVars(provider);
|
|
143
|
-
if (variables.length === 0) return load();
|
|
180
|
+
const withNuxtEnvironment = (variables, load) => {
|
|
144
181
|
const injected = [];
|
|
145
|
-
for (const
|
|
146
|
-
const keys = [variable.key, ...variable.aliases ?? []];
|
|
182
|
+
for (const keys of variables) {
|
|
147
183
|
if (keys.some((key) => process.env[key] !== void 0)) continue;
|
|
148
184
|
for (const key of keys) {
|
|
149
185
|
const value = process.env[`NUXT_${key}`];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../src/runtime/registry.ts"],"sourcesContent":["import {\n createFiles,\n type Adapter,\n type ExtensionsOf,\n type Files,\n type FilesActionEvent,\n type FilesErrorEvent,\n type FilesRetryEvent,\n type ProviderSlug,\n} from 'files-sdk'\nimport { getProvider, listEnvVars } from 'files-sdk/providers'\n\nimport type {\n DevelopmentOnlyNamedFilesConfig,\n DevelopmentOnlySingleFilesConfig,\n FilesConfig,\n NamedFilesConfig,\n SingleFilesConfig,\n StorageConfig,\n} from '../config'\nimport { createFilesDevtoolsDiagnostic, type FilesDevtoolsDiagnostic } from '../devtools/diagnostics'\nimport type { FilesDevtoolsSnapshot } from '../devtools/snapshot'\n\n/** Native Files client plus the methods contributed by a storage's plugins. */\nexport type FilesForStorage<T extends StorageConfig> = Files & ExtensionsOf<NonNullable<T['plugins']>>\n\n/** Map each configured storage name to its native Files client and plugin extensions. */\nexport type StorageRegistry<C extends FilesConfig> =\n C extends NamedFilesConfig<infer Storages>\n ? { [Name in keyof Storages]: FilesForStorage<Storages[Name]> }\n : C extends DevelopmentOnlyNamedFilesConfig<infer Storages>\n ? { [Name in keyof Storages]: FilesForStorage<Storages[Name]> }\n : Record<never, never>\n\n/** Files client returned by an unnamed single-storage configuration. */\nexport type SingleStorage<C extends FilesConfig> =\n C extends SingleFilesConfig<infer Storage>\n ? FilesForStorage<Storage>\n : C extends DevelopmentOnlySingleFilesConfig<infer Storage>\n ? FilesForStorage<Storage>\n : never\n\n/** Hooks emitted by the Nuxt/Nitro bridge after the storage's native hooks. */\nexport interface FilesRuntimeHooks {\n /** Observe a failed native Files operation. */\n onError?: (event: FilesErrorEvent, storage?: string) => void | Promise<void>\n /** Observe a completed native Files operation. */\n onAction?: (event: FilesActionEvent, storage?: string) => void | Promise<void>\n /** Observe a native Files retry. */\n onRetry?: (event: FilesRetryEvent, storage?: string) => void | Promise<void>\n}\n\n/** One provider factory statically supplied by the generated Nitro plugin. */\nexport type FilesProviderFactory = (config: never) => Adapter\n/** Provider factories available in the current build. */\nexport type FilesProviderFactories = Partial<Record<ProviderSlug, FilesProviderFactory>>\n\nconst runHooks = async (...hooks: (() => void | Promise<void> | undefined)[]): Promise<void> => {\n for (const hook of hooks) {\n try {\n // Preserve user-before-bridge ordering without exposing hook failures to native operations.\n // oxlint-disable-next-line no-await-in-loop\n await hook()\n } catch {}\n }\n}\n\nconst isStorageConfig = (value: unknown): value is StorageConfig =>\n Boolean(value && typeof value === 'object' && 'adapter' in value && typeof value.adapter === 'string')\nconst isStorageRecord = (value: unknown): value is Record<string, StorageConfig> =>\n Boolean(value && typeof value === 'object' && Object.values(value).every(isStorageConfig))\n\ntype StorageEntry = {\n name: string | undefined\n storage: StorageConfig\n override: StorageConfig | undefined\n source: 'storage' | 'devStorage'\n}\n\n/** Lazily construct and memoize native Files clients for a validated project configuration. */\nexport class FilesRegistry<const C extends FilesConfig = FilesConfig> {\n readonly #config: C\n readonly #development: boolean\n readonly #factories: FilesProviderFactories\n readonly #hooks: FilesRuntimeHooks\n readonly #instances = new Map<string, Files>()\n readonly #initializing = new Set<string>()\n readonly #diagnostics = new Map<string, FilesDevtoolsDiagnostic>()\n\n /** Create a registry without constructing a provider. */\n constructor(\n config: C,\n options: {\n development?: boolean\n factories: FilesProviderFactories\n hooks?: FilesRuntimeHooks\n },\n ) {\n if ('default' in config) {\n throw new Error('[nuxt-files-sdk:invalid-config] The default option has been removed.')\n }\n const development = options.development ?? false\n if (!config.storage && (!development || !config.devStorage)) {\n throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n }\n if (\n config.storage &&\n !isStorageConfig(config.storage) &&\n (!isStorageRecord(config.storage) || Object.keys(config.storage).length === 0)\n ) {\n throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n }\n if (!config.storage && !isStorageConfig(config.devStorage)) {\n if (!isStorageRecord(config.devStorage) || Object.keys(config.devStorage).length === 0) {\n throw new Error('[nuxt-files-sdk:invalid-config] At least one development storage is required.')\n }\n } else if (config.storage && !isStorageConfig(config.storage)) {\n if (config.devStorage && !isStorageRecord(config.devStorage)) {\n throw new Error('[nuxt-files-sdk:invalid-config] Named storage requires named devStorage overrides.')\n }\n for (const name of Object.keys(config.devStorage ?? {})) {\n if (!Object.hasOwn(config.storage, name)) {\n throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n }\n }\n }\n this.#config = config\n this.#development = development\n this.#factories = options.factories\n this.#hooks = options.hooks ?? {}\n }\n\n /** Return the client from an unnamed single-storage configuration. */\n get(...args: C extends SingleFilesConfig | DevelopmentOnlySingleFilesConfig ? [] : [name: never]): SingleStorage<C>\n /** Return one named storage client. */\n get<Name extends Extract<keyof StorageRegistry<C>, string>>(name: Name): StorageRegistry<C>[Name]\n get(name?: string): Files {\n const entry = this.#entry(name)\n const key = entry.name ?? ''\n const cached = this.#instances.get(key)\n if (cached) return cached\n if (this.#initializing.has(key)) {\n throw new Error('[nuxt-files-sdk:circular-initialization] Storage configuration cannot access itself.')\n }\n this.#initializing.add(key)\n try {\n const files = this.#create(entry)\n this.#instances.set(key, files)\n this.#diagnostics.delete(key)\n return files\n } catch (error) {\n const label = entry.name === undefined ? 'The single storage' : `Storage \"${entry.name}\"`\n this.#diagnostics.set(\n key,\n createFilesDevtoolsDiagnostic(\n 'NUXT_FILES_ADAPTER_INIT_FAILED',\n `${label} (${entry.override?.adapter ?? entry.storage.adapter}) could not be initialized.`,\n ),\n )\n throw error\n } finally {\n this.#initializing.delete(key)\n }\n }\n\n /** Return secret-free storage metadata and initialization state for development diagnostics. */\n inspect(): FilesDevtoolsSnapshot {\n return {\n storages: this.#entries().map(({ name, storage, override, source }) => ({\n ...(name === undefined ? {} : { name }),\n adapter: override?.adapter ?? storage.adapter,\n plugins: storage.plugins?.map((plugin) => plugin.name) ?? [],\n source,\n initialized: this.#instances.has(name ?? ''),\n })),\n diagnostics: [...this.#diagnostics.values()],\n }\n }\n\n #entries(): StorageEntry[] {\n const storage = this.#config.storage\n const devStorage = this.#config.devStorage\n if (!storage) {\n if (isStorageConfig(devStorage)) {\n return [{ name: undefined, storage: devStorage, override: undefined, source: 'devStorage' }]\n }\n return Object.entries(devStorage ?? {}).map(([name, developmentStorage]) => ({\n name,\n storage: developmentStorage,\n override: undefined,\n source: 'devStorage',\n }))\n }\n if (isStorageConfig(storage)) {\n const override = this.#development && isStorageConfig(devStorage) ? devStorage : undefined\n return [{ name: undefined, storage, override, source: override ? 'devStorage' : 'storage' }]\n }\n const overrides = this.#development && isStorageRecord(devStorage) ? devStorage : undefined\n return Object.entries(storage).map(([name, namedStorage]) => ({\n name,\n storage: namedStorage,\n override: overrides?.[name],\n source: overrides?.[name] ? 'devStorage' : 'storage',\n }))\n }\n\n #entry(name?: string): StorageEntry {\n const entries = this.#entries()\n if (entries.length === 1 && entries[0]?.name === undefined) {\n if (name !== undefined) {\n throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n }\n return entries[0]!\n }\n if (name === undefined) {\n throw new Error('[nuxt-files-sdk:storage-name-required] A storage name is required.')\n }\n const entry = entries.find((candidate) => candidate.name === name)\n if (!entry) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n return entry\n }\n\n #create({ name, storage, override }: StorageEntry): Files {\n const selected = override ?? storage\n const factory = this.#factories[selected.adapter]\n if (!factory) {\n throw new Error(\n `[nuxt-files-sdk:adapter-not-generated] Adapter \"${selected.adapter}\" is not available in this build.`,\n )\n }\n const adapter = withNuxtEnvironment(selected.adapter, () => {\n const input = typeof selected.config === 'function' ? selected.config() : selected.config\n if (input && typeof input === 'object' && 'then' in input) {\n throw new Error('[nuxt-files-sdk:async-config] Storage config functions must be synchronous.')\n }\n // Generated factories and configs share an adapter key; the broad registry type erases that correlation.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return factory(input as never)\n })\n return createFiles({\n adapter,\n hooks: {\n onAction: (event) =>\n runHooks(\n () => storage.hooks?.onAction?.(event),\n () => this.#hooks.onAction?.(event, name),\n ),\n onError: (event) =>\n runHooks(\n () => storage.hooks?.onError?.(event),\n () => this.#hooks.onError?.(event, name),\n ),\n onRetry: (event) =>\n runHooks(\n () => storage.hooks?.onRetry?.(event),\n () => this.#hooks.onRetry?.(event, name),\n ),\n },\n ...(storage.plugins ? { plugins: storage.plugins } : {}),\n ...(storage.prefix === undefined ? {} : { prefix: storage.prefix }),\n ...(storage.retries === undefined ? {} : { retries: storage.retries }),\n ...(storage.timeout === undefined ? {} : { timeout: storage.timeout }),\n })\n }\n}\n\n/** Bridge only NUXT_ aliases declared by the configured native provider during synchronous construction. */\nexport const withNuxtEnvironment = <T>(provider: ProviderSlug, load: () => T): T => {\n const metadata = getProvider(provider)\n if (!metadata) return load()\n const variables = listEnvVars(provider)\n if (variables.length === 0) return load()\n const injected: string[] = []\n for (const variable of variables) {\n const keys = [variable.key, ...(variable.aliases ?? [])]\n if (keys.some((key) => process.env[key] !== undefined)) continue\n for (const key of keys) {\n const value = process.env[`NUXT_${key}`]\n if (value !== undefined && process.env[key] === undefined) {\n process.env[key] = value\n injected.push(key)\n }\n }\n }\n try {\n return load()\n } finally {\n for (const key of injected) delete process.env[key]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MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAA,CAAS,GAAG;EACxD,KAAK,MAAM,OAAO,MAAM;GACpB,MAAM,QAAQ,QAAQ,IAAI,QAAQ;GAClC,IAAI,UAAU,KAAA,KAAa,QAAQ,IAAI,SAAS,KAAA,GAAW;IACvD,QAAQ,IAAI,OAAO;IACnB,SAAS,KAAK,GAAG;GACrB;EACJ;CACJ;CACA,IAAI;EACA,OAAO,KAAK;CAChB,UAAU;EACN,KAAK,MAAM,OAAO,UAAU,OAAO,QAAQ,IAAI;CACnD;AACJ"}
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../src/runtime/registry.ts"],"sourcesContent":["import {\n createFiles,\n type Adapter,\n type ExtensionsOf,\n type Files,\n type FilesActionEvent,\n type FilesErrorEvent,\n type FilesRetryEvent,\n type ProviderSlug,\n} from 'files-sdk'\n\nimport type { FilesConfig, FilesConfigInput, StorageConfig } from '../config'\nimport type { FilesDevtoolsDiagnosticCode } from '../devtools/diagnostics'\nimport { normalizeFilesConfig, type StorageEntry } from './normalize'\nimport type { ProviderFactories } from './provider-types'\n\n/** Native Files client plus the methods contributed by a storage's plugins. */\ntype AdapterFor<A> = A extends ProviderSlug\n ? ReturnType<ProviderFactories[A]>\n : A extends (...args: never[]) => Adapter\n ? ReturnType<A>\n : never\ntype PluginsFor<T> = T extends { plugins: infer V }\n ? V extends (...args: never[]) => infer P\n ? P extends readonly import('files-sdk').FilesPlugin[]\n ? P\n : never\n : V extends readonly import('files-sdk').FilesPlugin[]\n ? V\n : never\n : never\nexport type FilesForStorage<T extends { adapter: ProviderSlug | ((...args: never[]) => Adapter) }> = Files<\n AdapterFor<T['adapter']>\n> &\n ExtensionsOf<PluginsFor<T>>\n\ntype StorageOf<C> = C extends { storage: infer S } ? S : never\ntype StorageBranch<C> =\n | StorageOf<C>\n | StorageOf<C extends { $development: infer E } ? E : never>\n | StorageOf<C extends { $production: infer E } ? E : never>\n | StorageOf<C extends { $test: infer E } ? E : never>\n | StorageOf<C extends { $prerender: infer E } ? E : never>\n | StorageOf<C extends { $env: infer E } ? E[keyof E] : never>\ntype SingleEntry<C> = Extract<StorageBranch<C>, { adapter: ProviderSlug | ((...args: never[]) => Adapter) }>\ntype NamedSet<C> = Exclude<StorageBranch<C>, { adapter: unknown }>\ntype StorageNames<C> = NamedSet<C> extends infer S ? (S extends object ? keyof S : never) : never\ntype NamedEntry<C, Name extends PropertyKey> =\n NamedSet<C> extends infer S ? (S extends object ? (Name extends keyof S ? S[Name] : never) : never) : never\n/** Map each configured storage name to its native Files client and plugin extensions. */\nexport type StorageRegistry<C extends FilesConfigInput> = {\n [Name in StorageNames<C>]: FilesForStorage<\n Extract<NamedEntry<C, Name>, { adapter: ProviderSlug | ((...args: never[]) => Adapter) }>\n >\n}\n\n/** Files client returned by an unnamed single-storage configuration. */\nexport type SingleStorage<C extends FilesConfigInput> = FilesForStorage<SingleEntry<C>>\n\n/** Hooks emitted by the Nuxt/Nitro bridge after the storage's native hooks. */\nexport interface FilesRuntimeHooks {\n /** Observe a failed native Files operation. */\n onError?: (event: FilesErrorEvent, storage?: string) => void | Promise<void>\n /** Observe a completed native Files operation. */\n onAction?: (event: FilesActionEvent, storage?: string) => void | Promise<void>\n /** Observe a native Files retry. */\n onRetry?: (event: FilesRetryEvent, storage?: string) => void | Promise<void>\n}\n\n/** One provider factory statically supplied by the generated Nitro plugin. */\nexport type FilesProviderFactory = (config: never) => Adapter\n/** Provider factories available in the current build. */\nexport type FilesProviderFactories = Partial<Record<ProviderSlug, FilesProviderFactory>>\n\nconst runHooks = async (...hooks: (() => void | Promise<void> | undefined)[]): Promise<void> => {\n for (const hook of hooks) {\n try {\n // Preserve user-before-bridge ordering without exposing hook failures to native operations.\n // oxlint-disable-next-line no-await-in-loop\n await hook()\n } catch {}\n }\n}\n\nconst nativeFilesOptions = ({\n adapter: _adapter,\n config: _config,\n hooks: _hooks,\n plugins: _plugins,\n ...options\n}: StorageConfig) => options\n\nexport type ProviderEnvironment = Partial<Record<ProviderSlug, readonly (readonly string[])[]>>\nexport interface RegistryDiagnostic {\n code: FilesDevtoolsDiagnosticCode\n name?: string\n adapter?: string\n}\n\n/** Lazily construct and memoize native Files clients for a validated project configuration. */\nexport class FilesRegistry<const C extends FilesConfig = FilesConfig> {\n readonly #entries: Map<string | undefined, StorageEntry>\n readonly #environment: ProviderEnvironment\n readonly #factories: FilesProviderFactories\n readonly #hooks: FilesRuntimeHooks\n readonly #adapters = new Map<string | undefined, Adapter>()\n readonly #adapterInitializing = new Set<string | undefined>()\n readonly #instances = new Map<string | undefined, Files>()\n readonly #filesInitializing = new Set<string | undefined>()\n readonly #pluginNames = new Map<string | undefined, string[]>()\n readonly #diagnostics = new Map<string | undefined, RegistryDiagnostic>()\n\n /** Create a registry without constructing a provider. */\n constructor(\n config: C,\n options: {\n environment?: ProviderEnvironment\n factories: FilesProviderFactories\n hooks?: FilesRuntimeHooks\n },\n ) {\n this.#entries = normalizeFilesConfig(config)\n if (!this.#entries.size) throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n this.#environment = options.environment ?? {}\n this.#factories = options.factories\n this.#hooks = options.hooks ?? {}\n }\n\n /** Return the client from an unnamed single-storage configuration. */\n get(...args: SingleEntry<C> extends never ? [name: never] : []): SingleStorage<C>\n /** Return one named storage client. */\n get<Name extends Extract<keyof StorageRegistry<C>, string>>(name: Name): StorageRegistry<C>[Name]\n get(...args: [] | [string]): unknown {\n const name = args[0]\n const entry = this.#entry(name)\n const key = entry.name\n const cached = this.#instances.get(key)\n if (cached) return cached\n if (this.#filesInitializing.has(key)) throw this.#circular(key)\n this.#filesInitializing.add(key)\n try {\n const files = this.#create(entry)\n this.#instances.set(key, files)\n this.#diagnostics.delete(key)\n return files\n } catch (error) {\n this.#diagnostics.set(key, {\n code: 'NUXT_FILES_ADAPTER_INIT_FAILED',\n ...(entry.name === undefined ? {} : { name: entry.name }),\n adapter: typeof entry.storage.adapter === 'string' ? entry.storage.adapter : 'custom',\n })\n throw error\n } finally {\n this.#filesInitializing.delete(key)\n }\n }\n\n /** Return secret-free storage metadata and initialization state for development diagnostics. */\n inspect() {\n return {\n storages: [...this.#entries.values()].map(({ name, storage }) => ({\n ...(name === undefined ? {} : { name }),\n adapter: typeof storage.adapter === 'string' ? storage.adapter : 'custom',\n plugins:\n this.#pluginNames.get(name) ??\n (Array.isArray(storage.plugins) ? storage.plugins.map((plugin) => plugin.name) : []),\n initialized: this.#instances.has(name),\n })),\n diagnostics: [...this.#diagnostics.values()],\n }\n }\n\n #entry(name?: string): StorageEntry {\n if (name === undefined && !this.#entries.has(undefined)) {\n throw new Error('[nuxt-files-sdk:storage-name-required] A storage name is required.')\n }\n const entry = this.#entries.get(name)\n if (!entry) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n return entry\n }\n\n /** Resolve one selected adapter without constructing its Files client. */\n resolveAdapter(name?: string): Adapter {\n const entry = this.#entry(name)\n const key = entry.name\n const cached = this.#adapters.get(key)\n if (cached) return cached\n if (this.#adapterInitializing.has(key)) throw this.#circular(key)\n this.#adapterInitializing.add(key)\n try {\n const adapter = this.#createAdapter(entry)\n this.#adapters.set(key, adapter)\n return adapter\n } finally {\n this.#adapterInitializing.delete(key)\n }\n }\n\n #circular(name?: string): Error {\n return new Error(\n `[nuxt-files-sdk:circular-initialization] Circular storage dependency${name ? ` at \"${name}\"` : ''}.`,\n )\n }\n\n #createAdapter({ storage: selected }: StorageEntry): Adapter {\n const factory = typeof selected.adapter === 'string' ? this.#factories[selected.adapter] : selected.adapter\n if (!factory) {\n throw new Error(\n `[nuxt-files-sdk:adapter-not-generated] Adapter \"${typeof selected.adapter === 'string' ? selected.adapter : 'custom'}\" is not available in this build.`,\n )\n }\n const environment = typeof selected.adapter === 'string' ? (this.#environment[selected.adapter] ?? []) : []\n return withNuxtEnvironment(environment, () => {\n const input = typeof selected.config === 'function' ? selected.config() : selected.config\n if (input && typeof input === 'object' && 'then' in input) {\n throw new Error('[nuxt-files-sdk:async-config] Storage config functions must be synchronous.')\n }\n const value =\n selected.adapter === 's3'\n ? withS3NuxtCredentials(input)\n : selected.adapter === 'bun-s3'\n ? withBunS3NuxtOptions(input)\n : input\n // Generated factories and configs share an adapter key; the broad registry type erases that correlation.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return factory(value as never)\n })\n }\n\n #create({ name, storage }: StorageEntry): Files {\n const adapter = this.resolveAdapter(name)\n const plugins =\n typeof storage.plugins === 'function'\n ? storage.plugins({ storage: (storageName) => this.resolveAdapter(storageName) })\n : storage.plugins\n const files = createFiles({\n adapter,\n ...nativeFilesOptions(storage),\n hooks: {\n onAction: (event) =>\n runHooks(\n () => storage.hooks?.onAction?.(event),\n () => this.#hooks.onAction?.(event, name),\n ),\n onError: (event) =>\n runHooks(\n () => storage.hooks?.onError?.(event),\n () => this.#hooks.onError?.(event, name),\n ),\n onRetry: (event) =>\n runHooks(\n () => storage.hooks?.onRetry?.(event),\n () => this.#hooks.onRetry?.(event, name),\n ),\n },\n ...(plugins ? { plugins } : {}),\n })\n if (plugins)\n this.#pluginNames.set(\n name,\n plugins.map((plugin) => plugin.name),\n )\n return files\n }\n}\n\n/** Pass NUXT_ credentials explicitly because the AWS SDK resolves its chain after construction. */\nconst withS3NuxtCredentials = (input: unknown): unknown => {\n if (!input || typeof input !== 'object' || 'credentials' in input) return input\n if (\n [\n 'AWS_ACCESS_KEY_ID',\n 'AWS_SECRET_ACCESS_KEY',\n 'AWS_PROFILE',\n 'AWS_WEB_IDENTITY_TOKEN_FILE',\n 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI',\n 'AWS_CONTAINER_CREDENTIALS_FULL_URI',\n ].some((key) => process.env[key] !== undefined)\n )\n return input\n const accessKeyId = process.env.NUXT_AWS_ACCESS_KEY_ID\n const secretAccessKey = process.env.NUXT_AWS_SECRET_ACCESS_KEY\n if (!accessKeyId || !secretAccessKey) return input\n return {\n ...input,\n credentials: {\n accessKeyId,\n secretAccessKey,\n ...((process.env.AWS_SESSION_TOKEN ?? process.env.NUXT_AWS_SESSION_TOKEN) && {\n sessionToken: process.env.AWS_SESSION_TOKEN ?? process.env.NUXT_AWS_SESSION_TOKEN,\n }),\n },\n }\n}\n\n/** Bun resolves these environment keys in its own client; pass NUXT_ aliases as explicit options. */\nconst withBunS3NuxtOptions = (input: unknown): unknown => {\n if (input && (typeof input !== 'object' || 'client' in input)) return input\n const options: Record<string, unknown> = { ...(typeof input === 'object' && input ? input : {}) }\n for (const [field, key, alias] of [\n ['accessKeyId', 'AWS_ACCESS_KEY_ID', 'S3_ACCESS_KEY_ID'],\n ['secretAccessKey', 'AWS_SECRET_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY'],\n ['sessionToken', 'AWS_SESSION_TOKEN', 'S3_SESSION_TOKEN'],\n ['region', 'AWS_REGION', 'S3_REGION'],\n ['bucket', 'AWS_BUCKET', 'S3_BUCKET'],\n ] as const) {\n if (Object.hasOwn(options, field) || process.env[key] !== undefined || process.env[alias] !== undefined)\n continue\n const value = process.env[`NUXT_${key}`] ?? process.env[`NUXT_${alias}`]\n if (value !== undefined) options[field] = value\n }\n return options\n}\n\n/** Bridge only NUXT_ aliases declared by the configured native provider during synchronous construction. */\nexport const withNuxtEnvironment = <T>(variables: readonly (readonly string[])[], load: () => T): T => {\n const injected: string[] = []\n for (const keys of variables) {\n if (keys.some((key) => process.env[key] !== undefined)) continue\n for (const key of keys) {\n const value = process.env[`NUXT_${key}`]\n if (value !== undefined && process.env[key] === undefined) {\n process.env[key] = value\n injected.push(key)\n }\n }\n }\n try {\n return load()\n } finally {\n for (const key of injected) delete process.env[key]\n }\n}\n"],"mappings":";;;AA0EA,MAAM,WAAW,OAAO,GAAG,UAAqE;CAC5F,KAAK,MAAM,QAAQ,OACf,IAAI;EAGA,MAAM,KAAK;CACf,QAAQ,CAAC;AAEjB;AAEA,MAAM,sBAAsB,EACxB,SAAS,UACT,QAAQ,SACR,OAAO,QACP,SAAS,UACT,GAAG,cACc;;AAU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AAQ;GAClC,IAAI,UAAU,KAAA,KAAa,QAAQ,IAAI,SAAS,KAAA,GAAW;IACvD,QAAQ,IAAI,OAAO;IACnB,SAAS,KAAK,GAAG;GACrB;EACJ;CACJ;CACA,IAAI;EACA,OAAO,KAAK;CAChB,UAAU;EACN,KAAK,MAAM,OAAO,UAAU,OAAO,QAAQ,IAAI;CACnD;AACJ"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FilesForStorage, FilesProviderFactories, FilesProviderFactory, FilesRegistry, FilesRuntimeHooks, SingleStorage, StorageRegistry } from "./runtime/registry.js";
|
|
4
|
-
import { Files } from "files-sdk";
|
|
1
|
+
import { FilesForStorage, SingleStorage, StorageRegistry } from "./runtime/registry.js";
|
|
2
|
+
import { Files, SyncOptions, TransferOptions } from "files-sdk";
|
|
5
3
|
//#region src/runtime.d.ts
|
|
6
4
|
/** Project storage names and plugin-extended Files clients supplied by generated declarations. */
|
|
7
5
|
export interface NuxtFilesStorageRegistry {}
|
|
8
6
|
/** Project single Files client supplied by generated declarations. */
|
|
9
7
|
export interface NuxtFilesSingleStorage {}
|
|
10
|
-
/** Configure the process-local Files registry used by {@link useServerFiles}. */
|
|
11
|
-
export declare const configureFiles: <const C extends FilesConfig>(config: C, options: ConstructorParameters<typeof FilesRegistry<C>>[1]) => FilesRegistry<C>;
|
|
12
|
-
/** Return secret-free diagnostics for the configured process-local Files registry. */
|
|
13
|
-
export declare const inspectFiles: () => FilesDevtoolsSnapshot;
|
|
14
8
|
/** Return the project's unnamed Files client, including its configured plugin extensions. */
|
|
15
9
|
export declare function useServerFiles(...args: keyof NuxtFilesStorageRegistry extends never ? [] : [name: never]): NuxtFilesSingleStorage extends {
|
|
16
10
|
value: infer Single;
|
|
17
11
|
} ? Single : Files;
|
|
18
12
|
/** Return a named project Files client, including that storage's configured plugin extensions. */
|
|
19
13
|
export declare function useServerFiles<Name extends Extract<keyof NuxtFilesStorageRegistry, string>>(name: Name): NuxtFilesStorageRegistry[Name];
|
|
14
|
+
type FilesInput<Name extends string = Extract<keyof NuxtFilesStorageRegistry, string>> = Files | Name;
|
|
15
|
+
/** Delegate a mirror operation to the native Files SDK. */
|
|
16
|
+
export declare const syncFiles: (source: FilesInput, destination: FilesInput, options?: SyncOptions) => Promise<import("files-sdk").SyncResult>;
|
|
17
|
+
/** Delegate a transfer operation to the native Files SDK. */
|
|
18
|
+
export declare const transferFiles: (source: FilesInput, destination: FilesInput, options?: TransferOptions) => Promise<import("files-sdk").TransferResult>;
|
|
20
19
|
//#endregion
|
|
21
|
-
export {
|
|
20
|
+
export type { FilesForStorage, SingleStorage, StorageRegistry };
|
|
22
21
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.js
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getFiles } from "./runtime/internal.js";
|
|
2
|
+
import { sync, transfer } from "files-sdk";
|
|
3
3
|
//#region src/runtime.ts
|
|
4
|
-
let registry;
|
|
5
|
-
let registryDiagnostic;
|
|
6
|
-
/** Configure the process-local Files registry used by {@link useServerFiles}. */
|
|
7
|
-
const configureFiles = (config, options) => {
|
|
8
|
-
try {
|
|
9
|
-
const value = new FilesRegistry(config, options);
|
|
10
|
-
registry = value;
|
|
11
|
-
registryDiagnostic = void 0;
|
|
12
|
-
return value;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
registry = void 0;
|
|
15
|
-
registryDiagnostic = createFilesDevtoolsDiagnostic("NUXT_FILES_INVALID_CONFIG");
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/** Return secret-free diagnostics for the configured process-local Files registry. */
|
|
20
|
-
const inspectFiles = () => registry?.inspect() ?? {
|
|
21
|
-
storages: [],
|
|
22
|
-
diagnostics: [registryDiagnostic ?? createFilesDevtoolsDiagnostic("NUXT_FILES_NOT_CONFIGURED")]
|
|
23
|
-
};
|
|
24
4
|
function useServerFiles(name) {
|
|
25
|
-
|
|
26
|
-
return name === void 0 ? registry.get() : registry.get(name);
|
|
5
|
+
return getFiles(name);
|
|
27
6
|
}
|
|
7
|
+
/** Delegate a mirror operation to the native Files SDK. */
|
|
8
|
+
const syncFiles = (source, destination, options) => sync(typeof source === "string" ? getFiles(source) : source, typeof destination === "string" ? getFiles(destination) : destination, options);
|
|
9
|
+
/** Delegate a transfer operation to the native Files SDK. */
|
|
10
|
+
const transferFiles = (source, destination, options) => transfer(typeof source === "string" ? getFiles(source) : source, typeof destination === "string" ? getFiles(destination) : destination, options);
|
|
28
11
|
//#endregion
|
|
29
|
-
export {
|
|
12
|
+
export { syncFiles, transferFiles, useServerFiles };
|
|
30
13
|
|
|
31
14
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"runtime.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["import { sync, transfer, type Files, type SyncOptions, type TransferOptions } from 'files-sdk'\n\nimport { getFiles } from './runtime/internal'\n\nexport type { FilesForStorage, SingleStorage, StorageRegistry } from './runtime/registry'\n\n/** Project storage names and plugin-extended Files clients supplied by generated declarations. */\nexport interface NuxtFilesStorageRegistry {}\n/** Project single Files client supplied by generated declarations. */\nexport interface NuxtFilesSingleStorage {}\n\n/** Return the project's unnamed Files client, including its configured plugin extensions. */\nexport function useServerFiles(\n ...args: keyof NuxtFilesStorageRegistry extends never ? [] : [name: never]\n): NuxtFilesSingleStorage extends { value: infer Single } ? Single : Files\n/** Return a named project Files client, including that storage's configured plugin extensions. */\nexport function useServerFiles<Name extends Extract<keyof NuxtFilesStorageRegistry, string>>(\n name: Name,\n): NuxtFilesStorageRegistry[Name]\nexport function useServerFiles(name?: string): Files {\n return getFiles(name)\n}\n\ntype FilesInput<Name extends string = Extract<keyof NuxtFilesStorageRegistry, string>> = Files | Name\n\n/** Delegate a mirror operation to the native Files SDK. */\nexport const syncFiles = (source: FilesInput, destination: FilesInput, options?: SyncOptions) =>\n sync(\n typeof source === 'string' ? getFiles(source) : source,\n typeof destination === 'string' ? getFiles(destination) : destination,\n options,\n )\n\n/** Delegate a transfer operation to the native Files SDK. */\nexport const transferFiles = (source: FilesInput, destination: FilesInput, options?: TransferOptions) =>\n transfer(\n typeof source === 'string' ? getFiles(source) : source,\n typeof destination === 'string' ? getFiles(destination) : destination,\n options,\n )\n"],"mappings":";;;AAmBA,SAAgB,eAAe,MAAsB;CACjD,OAAO,SAAS,IAAI;AACxB;;AAKA,MAAa,aAAa,QAAoB,aAAyB,YACnE,KACI,OAAO,WAAW,WAAW,SAAS,MAAM,IAAI,QAChD,OAAO,gBAAgB,WAAW,SAAS,WAAW,IAAI,aAC1D,OACJ;;AAGJ,MAAa,iBAAiB,QAAoB,aAAyB,YACvE,SACI,OAAO,WAAW,WAAW,SAAS,MAAM,IAAI,QAChD,OAAO,gBAAgB,WAAW,SAAS,WAAW,IAAI,aAC1D,OACJ"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-files-sdk",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"homepage": "https://
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Files SDK integration for Nuxt with DevTools",
|
|
5
|
+
"homepage": "https://nuxt-files-sdk.liria.me",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -18,19 +18,23 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/module.d.ts",
|
|
21
|
-
"import": "./dist/module.js"
|
|
21
|
+
"import": "./dist/module.js",
|
|
22
|
+
"default": "./dist/module.js"
|
|
22
23
|
},
|
|
23
24
|
"./config": {
|
|
24
25
|
"types": "./dist/config.d.ts",
|
|
25
|
-
"import": "./dist/config.js"
|
|
26
|
+
"import": "./dist/config.js",
|
|
27
|
+
"default": "./dist/config.js"
|
|
26
28
|
},
|
|
27
29
|
"./nitro": {
|
|
28
30
|
"types": "./dist/nitro.d.ts",
|
|
29
|
-
"import": "./dist/nitro.js"
|
|
31
|
+
"import": "./dist/nitro.js",
|
|
32
|
+
"default": "./dist/nitro.js"
|
|
30
33
|
},
|
|
31
34
|
"./runtime": {
|
|
32
35
|
"types": "./dist/runtime.d.ts",
|
|
33
|
-
"import": "./dist/runtime.js"
|
|
36
|
+
"import": "./dist/runtime.js",
|
|
37
|
+
"default": "./dist/runtime.js"
|
|
34
38
|
},
|
|
35
39
|
"./package.json": "./package.json"
|
|
36
40
|
},
|
|
@@ -45,27 +49,34 @@
|
|
|
45
49
|
"typecheck": "tsc --noEmit"
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
48
|
-
"@
|
|
52
|
+
"@babel/parser": "^7.29.9",
|
|
53
|
+
"@nuxt/devtools-kit": "4.0.0-beta.2",
|
|
49
54
|
"@nuxt/kit": "^4.5.2",
|
|
50
|
-
"
|
|
55
|
+
"c12": "^3.3.4",
|
|
56
|
+
"devframe": "^1.1.0",
|
|
51
57
|
"jiti": "^2.7.0"
|
|
52
58
|
},
|
|
53
59
|
"devDependencies": {
|
|
54
60
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
55
61
|
"@nuxt/schema": "^4.5.2",
|
|
56
|
-
"@types/node": "^26.
|
|
57
|
-
"@vitejs/devtools-kit": "^0.7.
|
|
58
|
-
"files-sdk": "^2.
|
|
62
|
+
"@types/node": "^26.6.3",
|
|
63
|
+
"@vitejs/devtools-kit": "^0.7.6",
|
|
64
|
+
"files-sdk": "^2.6.0",
|
|
65
|
+
"h3": "^1.15.11",
|
|
59
66
|
"publint": "^0.3.24",
|
|
60
67
|
"tsdown": "^0.23.0",
|
|
61
68
|
"typescript": "^7.0.2",
|
|
62
|
-
"vue": "^3.5.
|
|
69
|
+
"vue": "^3.5.43"
|
|
63
70
|
},
|
|
64
71
|
"peerDependencies": {
|
|
65
|
-
"files-sdk": "^2.
|
|
72
|
+
"files-sdk": "^2.6.0",
|
|
73
|
+
"h3": "^1.15.0 || ^2.0.1-rc.0",
|
|
66
74
|
"nuxt": "^4.0.0 || ^5.0.0"
|
|
67
75
|
},
|
|
68
76
|
"peerDependenciesMeta": {
|
|
77
|
+
"h3": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
69
80
|
"nuxt": {
|
|
70
81
|
"optional": true
|
|
71
82
|
}
|