@aigne/afs-cloudflare 1.11.0-beta.7
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.md +26 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/cache.cjs +37 -0
- package/dist/cache.mjs +37 -0
- package/dist/cache.mjs.map +1 -0
- package/dist/client.cjs +53 -0
- package/dist/client.mjs +53 -0
- package/dist/client.mjs.map +1 -0
- package/dist/cloudflare-afs.cjs +2724 -0
- package/dist/cloudflare-afs.d.cts +387 -0
- package/dist/cloudflare-afs.d.cts.map +1 -0
- package/dist/cloudflare-afs.d.mts +387 -0
- package/dist/cloudflare-afs.d.mts.map +1 -0
- package/dist/cloudflare-afs.mjs +2725 -0
- package/dist/cloudflare-afs.mjs.map +1 -0
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.cts +26 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +26 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +82 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +22 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +6 -0
- package/dist/platform-ref.cjs +20 -0
- package/dist/platform-ref.d.cts +11 -0
- package/dist/platform-ref.d.cts.map +1 -0
- package/dist/platform-ref.d.mts +11 -0
- package/dist/platform-ref.d.mts.map +1 -0
- package/dist/platform-ref.mjs +17 -0
- package/dist/platform-ref.mjs.map +1 -0
- package/dist/types.cjs +52 -0
- package/dist/types.d.cts +63 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +63 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +46 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +61 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. Unauthorized copying, modification, distribution, or use of
|
|
7
|
+
this Software, via any medium, is strictly prohibited.
|
|
8
|
+
|
|
9
|
+
The Software is provided for internal use only within ArcBlock, Inc. and its
|
|
10
|
+
authorized affiliates.
|
|
11
|
+
|
|
12
|
+
## No License Granted
|
|
13
|
+
|
|
14
|
+
No license, express or implied, is granted to any party for any purpose.
|
|
15
|
+
All rights are reserved by ArcBlock, Inc.
|
|
16
|
+
|
|
17
|
+
## Public Artifact Distribution
|
|
18
|
+
|
|
19
|
+
Portions of this Software may be released publicly under separate open-source
|
|
20
|
+
licenses (such as MIT License) through designated public repositories. Such
|
|
21
|
+
public releases are governed by their respective licenses and do not affect
|
|
22
|
+
the proprietary nature of this repository.
|
|
23
|
+
|
|
24
|
+
## Contact
|
|
25
|
+
|
|
26
|
+
For licensing inquiries, contact: legal@arcblock.io
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
|
|
3
|
+
function __decorate(decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.__decorate = __decorate;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { __decorate };
|
package/dist/cache.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/cache.ts
|
|
3
|
+
var CloudflareCache = class {
|
|
4
|
+
cache = /* @__PURE__ */ new Map();
|
|
5
|
+
defaultTtlMs;
|
|
6
|
+
disabled;
|
|
7
|
+
constructor(ttlSeconds = 30, disabled = false) {
|
|
8
|
+
this.defaultTtlMs = ttlSeconds * 1e3;
|
|
9
|
+
this.disabled = disabled;
|
|
10
|
+
}
|
|
11
|
+
get(key) {
|
|
12
|
+
if (this.disabled) return void 0;
|
|
13
|
+
const entry = this.cache.get(key);
|
|
14
|
+
if (!entry) return void 0;
|
|
15
|
+
if (Date.now() > entry.expiresAt) {
|
|
16
|
+
this.cache.delete(key);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return entry.value;
|
|
20
|
+
}
|
|
21
|
+
set(key, value) {
|
|
22
|
+
if (this.disabled) return;
|
|
23
|
+
this.cache.set(key, {
|
|
24
|
+
value,
|
|
25
|
+
expiresAt: Date.now() + this.defaultTtlMs
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
invalidate(prefix) {
|
|
29
|
+
for (const key of this.cache.keys()) if (key.startsWith(prefix)) this.cache.delete(key);
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
this.cache.clear();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.CloudflareCache = CloudflareCache;
|
package/dist/cache.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/cache.ts
|
|
2
|
+
var CloudflareCache = class {
|
|
3
|
+
cache = /* @__PURE__ */ new Map();
|
|
4
|
+
defaultTtlMs;
|
|
5
|
+
disabled;
|
|
6
|
+
constructor(ttlSeconds = 30, disabled = false) {
|
|
7
|
+
this.defaultTtlMs = ttlSeconds * 1e3;
|
|
8
|
+
this.disabled = disabled;
|
|
9
|
+
}
|
|
10
|
+
get(key) {
|
|
11
|
+
if (this.disabled) return void 0;
|
|
12
|
+
const entry = this.cache.get(key);
|
|
13
|
+
if (!entry) return void 0;
|
|
14
|
+
if (Date.now() > entry.expiresAt) {
|
|
15
|
+
this.cache.delete(key);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return entry.value;
|
|
19
|
+
}
|
|
20
|
+
set(key, value) {
|
|
21
|
+
if (this.disabled) return;
|
|
22
|
+
this.cache.set(key, {
|
|
23
|
+
value,
|
|
24
|
+
expiresAt: Date.now() + this.defaultTtlMs
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
invalidate(prefix) {
|
|
28
|
+
for (const key of this.cache.keys()) if (key.startsWith(prefix)) this.cache.delete(key);
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.cache.clear();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { CloudflareCache };
|
|
37
|
+
//# sourceMappingURL=cache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.mjs","names":[],"sources":["../src/cache.ts"],"sourcesContent":["interface CacheEntry<T> {\n value: T;\n expiresAt: number;\n}\n\nexport class CloudflareCache {\n private cache: Map<string, CacheEntry<unknown>> = new Map();\n private defaultTtlMs: number;\n private disabled: boolean;\n\n constructor(ttlSeconds = 30, disabled = false) {\n this.defaultTtlMs = ttlSeconds * 1000;\n this.disabled = disabled;\n }\n\n get<T>(key: string): T | undefined {\n if (this.disabled) return undefined;\n\n const entry = this.cache.get(key);\n if (!entry) return undefined;\n\n if (Date.now() > entry.expiresAt) {\n this.cache.delete(key);\n return undefined;\n }\n\n return entry.value as T;\n }\n\n set(key: string, value: unknown): void {\n if (this.disabled) return;\n\n this.cache.set(key, {\n value,\n expiresAt: Date.now() + this.defaultTtlMs,\n });\n }\n\n invalidate(prefix: string): void {\n for (const key of this.cache.keys()) {\n if (key.startsWith(prefix)) {\n this.cache.delete(key);\n }\n }\n }\n\n clear(): void {\n this.cache.clear();\n }\n}\n"],"mappings":";AAKA,IAAa,kBAAb,MAA6B;CAC3B,AAAQ,wBAA0C,IAAI,KAAK;CAC3D,AAAQ;CACR,AAAQ;CAER,YAAY,aAAa,IAAI,WAAW,OAAO;AAC7C,OAAK,eAAe,aAAa;AACjC,OAAK,WAAW;;CAGlB,IAAO,KAA4B;AACjC,MAAI,KAAK,SAAU,QAAO;EAE1B,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO,QAAO;AAEnB,MAAI,KAAK,KAAK,GAAG,MAAM,WAAW;AAChC,QAAK,MAAM,OAAO,IAAI;AACtB;;AAGF,SAAO,MAAM;;CAGf,IAAI,KAAa,OAAsB;AACrC,MAAI,KAAK,SAAU;AAEnB,OAAK,MAAM,IAAI,KAAK;GAClB;GACA,WAAW,KAAK,KAAK,GAAG,KAAK;GAC9B,CAAC;;CAGJ,WAAW,QAAsB;AAC/B,OAAK,MAAM,OAAO,KAAK,MAAM,MAAM,CACjC,KAAI,IAAI,WAAW,OAAO,CACxB,MAAK,MAAM,OAAO,IAAI;;CAK5B,QAAc;AACZ,OAAK,MAAM,OAAO"}
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/client.ts
|
|
3
|
+
var CloudflareClient = class {
|
|
4
|
+
client = null;
|
|
5
|
+
config;
|
|
6
|
+
_accountId;
|
|
7
|
+
_accountIdResolved = false;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
this._accountId = config.accountId;
|
|
11
|
+
}
|
|
12
|
+
getClient() {
|
|
13
|
+
if (!this.client) throw new Error("Cloudflare client not initialized. Call setClient() or ensureClient() first.");
|
|
14
|
+
return this.client;
|
|
15
|
+
}
|
|
16
|
+
async ensureClient() {
|
|
17
|
+
if (!this.client) {
|
|
18
|
+
const { default: CloudflareCtor } = await import("cloudflare");
|
|
19
|
+
this.client = new CloudflareCtor({ apiToken: this.config.apiToken });
|
|
20
|
+
}
|
|
21
|
+
return this.client;
|
|
22
|
+
}
|
|
23
|
+
setClient(client) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
}
|
|
26
|
+
/** @deprecated Use ensureClient() instead */
|
|
27
|
+
async initClient() {
|
|
28
|
+
await this.ensureClient();
|
|
29
|
+
}
|
|
30
|
+
async getAccountId() {
|
|
31
|
+
await this.ensureClient();
|
|
32
|
+
if (this._accountId) return this._accountId;
|
|
33
|
+
if (!this._accountIdResolved) {
|
|
34
|
+
const accounts = await this.getClient().accounts.list();
|
|
35
|
+
const accountList = [];
|
|
36
|
+
for await (const account of accounts) accountList.push(account);
|
|
37
|
+
if (accountList.length === 0) throw new Error("No Cloudflare accounts found for this API token");
|
|
38
|
+
if (accountList.length > 1) throw new Error(`Multiple Cloudflare accounts found (${accountList.length}). Please specify 'accountId' explicitly.`);
|
|
39
|
+
this._accountId = accountList[0].id;
|
|
40
|
+
this._accountIdResolved = true;
|
|
41
|
+
}
|
|
42
|
+
return this._accountId;
|
|
43
|
+
}
|
|
44
|
+
async destroy() {
|
|
45
|
+
this.client = null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function createCloudflareClient(config) {
|
|
49
|
+
return new CloudflareClient(config);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
exports.createCloudflareClient = createCloudflareClient;
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/client.ts
|
|
2
|
+
var CloudflareClient = class {
|
|
3
|
+
client = null;
|
|
4
|
+
config;
|
|
5
|
+
_accountId;
|
|
6
|
+
_accountIdResolved = false;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this._accountId = config.accountId;
|
|
10
|
+
}
|
|
11
|
+
getClient() {
|
|
12
|
+
if (!this.client) throw new Error("Cloudflare client not initialized. Call setClient() or ensureClient() first.");
|
|
13
|
+
return this.client;
|
|
14
|
+
}
|
|
15
|
+
async ensureClient() {
|
|
16
|
+
if (!this.client) {
|
|
17
|
+
const { default: CloudflareCtor } = await import("cloudflare");
|
|
18
|
+
this.client = new CloudflareCtor({ apiToken: this.config.apiToken });
|
|
19
|
+
}
|
|
20
|
+
return this.client;
|
|
21
|
+
}
|
|
22
|
+
setClient(client) {
|
|
23
|
+
this.client = client;
|
|
24
|
+
}
|
|
25
|
+
/** @deprecated Use ensureClient() instead */
|
|
26
|
+
async initClient() {
|
|
27
|
+
await this.ensureClient();
|
|
28
|
+
}
|
|
29
|
+
async getAccountId() {
|
|
30
|
+
await this.ensureClient();
|
|
31
|
+
if (this._accountId) return this._accountId;
|
|
32
|
+
if (!this._accountIdResolved) {
|
|
33
|
+
const accounts = await this.getClient().accounts.list();
|
|
34
|
+
const accountList = [];
|
|
35
|
+
for await (const account of accounts) accountList.push(account);
|
|
36
|
+
if (accountList.length === 0) throw new Error("No Cloudflare accounts found for this API token");
|
|
37
|
+
if (accountList.length > 1) throw new Error(`Multiple Cloudflare accounts found (${accountList.length}). Please specify 'accountId' explicitly.`);
|
|
38
|
+
this._accountId = accountList[0].id;
|
|
39
|
+
this._accountIdResolved = true;
|
|
40
|
+
}
|
|
41
|
+
return this._accountId;
|
|
42
|
+
}
|
|
43
|
+
async destroy() {
|
|
44
|
+
this.client = null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function createCloudflareClient(config) {
|
|
48
|
+
return new CloudflareClient(config);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { createCloudflareClient };
|
|
53
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type Cloudflare from \"cloudflare\";\nimport type { NormalizedConfig } from \"./types.js\";\n\nexport class CloudflareClient {\n private client: Cloudflare | null = null;\n private config: NormalizedConfig;\n private _accountId: string | undefined;\n private _accountIdResolved = false;\n\n constructor(config: NormalizedConfig) {\n this.config = config;\n this._accountId = config.accountId;\n }\n\n getClient(): Cloudflare {\n if (!this.client) {\n throw new Error(\n \"Cloudflare client not initialized. Call setClient() or ensureClient() first.\",\n );\n }\n return this.client;\n }\n\n async ensureClient(): Promise<Cloudflare> {\n if (!this.client) {\n const { default: CloudflareCtor } = await import(\"cloudflare\");\n this.client = new CloudflareCtor({\n apiToken: this.config.apiToken,\n });\n }\n return this.client;\n }\n\n setClient(client: Cloudflare): void {\n this.client = client;\n }\n\n /** @deprecated Use ensureClient() instead */\n async initClient(): Promise<void> {\n await this.ensureClient();\n }\n\n async getAccountId(): Promise<string> {\n // Always ensure client is initialized (even if accountId is already known)\n await this.ensureClient();\n\n if (this._accountId) return this._accountId;\n\n if (!this._accountIdResolved) {\n const client = this.getClient();\n const accounts = await client.accounts.list();\n const accountList = [];\n for await (const account of accounts) {\n accountList.push(account);\n }\n\n if (accountList.length === 0) {\n throw new Error(\"No Cloudflare accounts found for this API token\");\n }\n if (accountList.length > 1) {\n throw new Error(\n `Multiple Cloudflare accounts found (${accountList.length}). Please specify 'accountId' explicitly.`,\n );\n }\n\n this._accountId = accountList[0]!.id;\n this._accountIdResolved = true;\n }\n\n return this._accountId!;\n }\n\n async destroy(): Promise<void> {\n this.client = null;\n }\n}\n\nexport function createCloudflareClient(config: NormalizedConfig): CloudflareClient {\n return new CloudflareClient(config);\n}\n"],"mappings":";AAGA,IAAa,mBAAb,MAA8B;CAC5B,AAAQ,SAA4B;CACpC,AAAQ;CACR,AAAQ;CACR,AAAQ,qBAAqB;CAE7B,YAAY,QAA0B;AACpC,OAAK,SAAS;AACd,OAAK,aAAa,OAAO;;CAG3B,YAAwB;AACtB,MAAI,CAAC,KAAK,OACR,OAAM,IAAI,MACR,+EACD;AAEH,SAAO,KAAK;;CAGd,MAAM,eAAoC;AACxC,MAAI,CAAC,KAAK,QAAQ;GAChB,MAAM,EAAE,SAAS,mBAAmB,MAAM,OAAO;AACjD,QAAK,SAAS,IAAI,eAAe,EAC/B,UAAU,KAAK,OAAO,UACvB,CAAC;;AAEJ,SAAO,KAAK;;CAGd,UAAU,QAA0B;AAClC,OAAK,SAAS;;;CAIhB,MAAM,aAA4B;AAChC,QAAM,KAAK,cAAc;;CAG3B,MAAM,eAAgC;AAEpC,QAAM,KAAK,cAAc;AAEzB,MAAI,KAAK,WAAY,QAAO,KAAK;AAEjC,MAAI,CAAC,KAAK,oBAAoB;GAE5B,MAAM,WAAW,MADF,KAAK,WAAW,CACD,SAAS,MAAM;GAC7C,MAAM,cAAc,EAAE;AACtB,cAAW,MAAM,WAAW,SAC1B,aAAY,KAAK,QAAQ;AAG3B,OAAI,YAAY,WAAW,EACzB,OAAM,IAAI,MAAM,kDAAkD;AAEpE,OAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MACR,uCAAuC,YAAY,OAAO,2CAC3D;AAGH,QAAK,aAAa,YAAY,GAAI;AAClC,QAAK,qBAAqB;;AAG5B,SAAO,KAAK;;CAGd,MAAM,UAAyB;AAC7B,OAAK,SAAS;;;AAIlB,SAAgB,uBAAuB,QAA4C;AACjF,QAAO,IAAI,iBAAiB,OAAO"}
|