sst 3.0.2 → 3.0.3

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.
@@ -1,4 +1,5 @@
1
1
  export interface Resource {
2
2
  [key: string]: any;
3
3
  }
4
+ export declare function fromCloudflareEnv(input: any): void;
4
5
  export declare const Resource: Resource;
package/dist/resource.js CHANGED
@@ -1,16 +1,22 @@
1
+ import { env } from "node:process";
1
2
  const raw = {
2
3
  // @ts-expect-error,
3
4
  ...globalThis.$SST_LINKS,
4
5
  };
5
- for (const [key, value] of Object.entries(process.env)) {
6
+ for (const [key, value] of Object.entries(env)) {
6
7
  if (key.startsWith("SST_RESOURCE_") && value) {
7
8
  raw[key.slice("SST_RESOURCE_".length)] = JSON.parse(value);
8
9
  }
9
10
  }
11
+ export function fromCloudflareEnv(input) {
12
+ for (const [key, value] of Object.entries(input)) {
13
+ raw[key] = value;
14
+ }
15
+ }
10
16
  export const Resource = new Proxy(raw, {
11
- get(target, prop) {
12
- if (prop in target) {
13
- return target[prop];
17
+ get(_target, prop) {
18
+ if (prop in raw) {
19
+ return raw[prop];
14
20
  }
15
21
  throw new Error(`"${prop}" is not linked`);
16
22
  },
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "sst",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
- "version": "3.0.2",
6
+ "version": "3.0.3",
7
7
  "main": "./dist/index.js",
8
8
  "exports": {
9
9
  ".": "./dist/index.js",