@jonsoc/console-resource 1.1.34

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/bun.lock ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "workspaces": {
4
+ "": {
5
+ "dependencies": {
6
+ "@cloudflare/workers-types": "^4.20250830.0",
7
+ },
8
+ },
9
+ },
10
+ "packages": {
11
+ "@cloudflare/workers-types": ["@cloudflare/workers-types@4.20250830.0", "", {}, "sha512-uAGZFqEBFnCiwIokxMnrrtjIkT8qyGT1LACSScEUyW7nKmtD0Viykp9QZWrIlssyEp/MDB6XsdALF8y6upxpcg=="],
12
+ }
13
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "@jonsoc/console-resource",
4
+ "version": "1.1.34",
5
+ "license": "MIT",
6
+ "dependencies": {
7
+ "@cloudflare/workers-types": "catalog:"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "production": {
12
+ "import": "./resource.cloudflare.ts"
13
+ },
14
+ "import": "./resource.node.ts"
15
+ }
16
+ },
17
+ "devDependencies": {
18
+ "@cloudflare/workers-types": "catalog:",
19
+ "@tsconfig/node22": "22.0.2",
20
+ "@types/node": "catalog:",
21
+ "cloudflare": "5.2.0"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ }
26
+ }
@@ -0,0 +1,19 @@
1
+ import { env } from "cloudflare:workers"
2
+ export { waitUntil } from "cloudflare:workers"
3
+
4
+ export const Resource = new Proxy(
5
+ {},
6
+ {
7
+ get(_target, prop: string) {
8
+ if (prop in env) {
9
+ // @ts-expect-error
10
+ const value = env[prop]
11
+ return typeof value === "string" ? JSON.parse(value) : value
12
+ } else if (prop === "App") {
13
+ // @ts-expect-error
14
+ return JSON.parse(env.SST_RESOURCE_App)
15
+ }
16
+ throw new Error(`"${prop}" is not linked in your sst.config.ts (cloudflare)`)
17
+ },
18
+ },
19
+ ) as Record<string, any>
@@ -0,0 +1,70 @@
1
+ import type { KVNamespaceListOptions, KVNamespaceListResult, KVNamespacePutOptions } from "@cloudflare/workers-types"
2
+ import { Resource as ResourceBase } from "sst"
3
+ import Cloudflare from "cloudflare"
4
+
5
+ export const waitUntil = async (promise: Promise<any>) => {
6
+ await promise
7
+ }
8
+
9
+ export const Resource = new Proxy(
10
+ {},
11
+ {
12
+ get(_target, prop: keyof typeof ResourceBase) {
13
+ const value = ResourceBase[prop]
14
+ if ("type" in value) {
15
+ // @ts-ignore
16
+ if (value.type === "sst.cloudflare.Bucket") {
17
+ return {
18
+ put: async () => {},
19
+ }
20
+ }
21
+ // @ts-ignore
22
+ if (value.type === "sst.cloudflare.Kv") {
23
+ const client = new Cloudflare({
24
+ apiToken: ResourceBase.CLOUDFLARE_API_TOKEN.value,
25
+ })
26
+ // @ts-ignore
27
+ const namespaceId = value.namespaceId
28
+ const accountId = ResourceBase.CLOUDFLARE_DEFAULT_ACCOUNT_ID.value
29
+ return {
30
+ get: (k: string | string[]) => {
31
+ const isMulti = Array.isArray(k)
32
+ return client.kv.namespaces
33
+ .bulkGet(namespaceId, {
34
+ keys: Array.isArray(k) ? k : [k],
35
+ account_id: accountId,
36
+ })
37
+ .then((result) => (isMulti ? new Map(Object.entries(result?.values ?? {})) : result?.values?.[k]))
38
+ },
39
+ put: (k: string, v: string, opts?: KVNamespacePutOptions) =>
40
+ client.kv.namespaces.values.update(namespaceId, k, {
41
+ account_id: accountId,
42
+ value: v,
43
+ expiration: opts?.expiration,
44
+ expiration_ttl: opts?.expirationTtl,
45
+ metadata: opts?.metadata,
46
+ }),
47
+ delete: (k: string) =>
48
+ client.kv.namespaces.values.delete(namespaceId, k, {
49
+ account_id: accountId,
50
+ }),
51
+ list: (opts?: KVNamespaceListOptions): Promise<KVNamespaceListResult<unknown, string>> =>
52
+ client.kv.namespaces.keys
53
+ .list(namespaceId, {
54
+ account_id: accountId,
55
+ prefix: opts?.prefix ?? undefined,
56
+ })
57
+ .then((result) => {
58
+ return {
59
+ keys: result.result,
60
+ list_complete: true,
61
+ cacheStatus: null,
62
+ }
63
+ }),
64
+ }
65
+ }
66
+ }
67
+ return value
68
+ },
69
+ },
70
+ ) as Record<string, any>
package/sst-env.d.ts ADDED
@@ -0,0 +1,187 @@
1
+ /* This file is auto-generated by SST. Do not edit. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /* deno-fmt-ignore-file */
5
+
6
+ import "sst"
7
+ declare module "sst" {
8
+ export interface Resource {
9
+ "ADMIN_SECRET": {
10
+ "type": "sst.sst.Secret"
11
+ "value": string
12
+ }
13
+ "AUTH_API_URL": {
14
+ "type": "sst.sst.Linkable"
15
+ "value": string
16
+ }
17
+ "AWS_SES_ACCESS_KEY_ID": {
18
+ "type": "sst.sst.Secret"
19
+ "value": string
20
+ }
21
+ "AWS_SES_SECRET_ACCESS_KEY": {
22
+ "type": "sst.sst.Secret"
23
+ "value": string
24
+ }
25
+ "CLOUDFLARE_API_TOKEN": {
26
+ "type": "sst.sst.Secret"
27
+ "value": string
28
+ }
29
+ "CLOUDFLARE_DEFAULT_ACCOUNT_ID": {
30
+ "type": "sst.sst.Secret"
31
+ "value": string
32
+ }
33
+ "Console": {
34
+ "type": "sst.cloudflare.SolidStart"
35
+ "url": string
36
+ }
37
+ "DISCORD_SUPPORT_BOT_TOKEN": {
38
+ "type": "sst.sst.Secret"
39
+ "value": string
40
+ }
41
+ "DISCORD_SUPPORT_CHANNEL_ID": {
42
+ "type": "sst.sst.Secret"
43
+ "value": string
44
+ }
45
+ "Database": {
46
+ "database": string
47
+ "host": string
48
+ "password": string
49
+ "port": number
50
+ "type": "sst.sst.Linkable"
51
+ "username": string
52
+ }
53
+ "EMAILOCTOPUS_API_KEY": {
54
+ "type": "sst.sst.Secret"
55
+ "value": string
56
+ }
57
+ "FEISHU_APP_ID": {
58
+ "type": "sst.sst.Secret"
59
+ "value": string
60
+ }
61
+ "FEISHU_APP_SECRET": {
62
+ "type": "sst.sst.Secret"
63
+ "value": string
64
+ }
65
+ "GITHUB_APP_ID": {
66
+ "type": "sst.sst.Secret"
67
+ "value": string
68
+ }
69
+ "GITHUB_APP_PRIVATE_KEY": {
70
+ "type": "sst.sst.Secret"
71
+ "value": string
72
+ }
73
+ "GITHUB_CLIENT_ID_CONSOLE": {
74
+ "type": "sst.sst.Secret"
75
+ "value": string
76
+ }
77
+ "GITHUB_CLIENT_SECRET_CONSOLE": {
78
+ "type": "sst.sst.Secret"
79
+ "value": string
80
+ }
81
+ "GOOGLE_CLIENT_ID": {
82
+ "type": "sst.sst.Secret"
83
+ "value": string
84
+ }
85
+ "HONEYCOMB_API_KEY": {
86
+ "type": "sst.sst.Secret"
87
+ "value": string
88
+ }
89
+ "R2AccessKey": {
90
+ "type": "sst.sst.Secret"
91
+ "value": string
92
+ }
93
+ "R2SecretKey": {
94
+ "type": "sst.sst.Secret"
95
+ "value": string
96
+ }
97
+ "STRIPE_PUBLISHABLE_KEY": {
98
+ "type": "sst.sst.Secret"
99
+ "value": string
100
+ }
101
+ "STRIPE_SECRET_KEY": {
102
+ "type": "sst.sst.Secret"
103
+ "value": string
104
+ }
105
+ "STRIPE_WEBHOOK_SECRET": {
106
+ "type": "sst.sst.Linkable"
107
+ "value": string
108
+ }
109
+ "Teams": {
110
+ "type": "sst.cloudflare.SolidStart"
111
+ "url": string
112
+ }
113
+ "Web": {
114
+ "type": "sst.cloudflare.Astro"
115
+ "url": string
116
+ }
117
+ "WebApp": {
118
+ "type": "sst.cloudflare.StaticSite"
119
+ "url": string
120
+ }
121
+ "ZEN_BLACK_LIMITS": {
122
+ "type": "sst.sst.Secret"
123
+ "value": string
124
+ }
125
+ "ZEN_BLACK_PRICE": {
126
+ "plan100": string
127
+ "plan20": string
128
+ "plan200": string
129
+ "product": string
130
+ "type": "sst.sst.Linkable"
131
+ }
132
+ "ZEN_MODELS1": {
133
+ "type": "sst.sst.Secret"
134
+ "value": string
135
+ }
136
+ "ZEN_MODELS2": {
137
+ "type": "sst.sst.Secret"
138
+ "value": string
139
+ }
140
+ "ZEN_MODELS3": {
141
+ "type": "sst.sst.Secret"
142
+ "value": string
143
+ }
144
+ "ZEN_MODELS4": {
145
+ "type": "sst.sst.Secret"
146
+ "value": string
147
+ }
148
+ "ZEN_MODELS5": {
149
+ "type": "sst.sst.Secret"
150
+ "value": string
151
+ }
152
+ "ZEN_MODELS6": {
153
+ "type": "sst.sst.Secret"
154
+ "value": string
155
+ }
156
+ "ZEN_MODELS7": {
157
+ "type": "sst.sst.Secret"
158
+ "value": string
159
+ }
160
+ "ZEN_MODELS8": {
161
+ "type": "sst.sst.Secret"
162
+ "value": string
163
+ }
164
+ "ZEN_SESSION_SECRET": {
165
+ "type": "sst.sst.Secret"
166
+ "value": string
167
+ }
168
+ }
169
+ }
170
+ // cloudflare
171
+ import * as cloudflare from "@cloudflare/workers-types";
172
+ declare module "sst" {
173
+ export interface Resource {
174
+ "Api": cloudflare.Service
175
+ "AuthApi": cloudflare.Service
176
+ "AuthStorage": cloudflare.KVNamespace
177
+ "Bucket": cloudflare.R2Bucket
178
+ "EnterpriseStorage": cloudflare.R2Bucket
179
+ "GatewayKv": cloudflare.KVNamespace
180
+ "LogProcessor": cloudflare.Service
181
+ "ZenData": cloudflare.R2Bucket
182
+ "ZenDataNew": cloudflare.R2Bucket
183
+ }
184
+ }
185
+
186
+ import "sst"
187
+ export {}
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "@tsconfig/node22/tsconfig.json",
4
+ "compilerOptions": {
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "types": ["@cloudflare/workers-types", "node"]
8
+ }
9
+ }