@sentry/cloudflare 10.39.0 → 10.41.0-beta.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.
Files changed (43) hide show
  1. package/build/cjs/durableobject.js +9 -133
  2. package/build/cjs/durableobject.js.map +1 -1
  3. package/build/cjs/handler.js +6 -6
  4. package/build/cjs/handler.js.map +1 -1
  5. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +52 -0
  6. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  7. package/build/cjs/utils/instrumentContext.js +103 -0
  8. package/build/cjs/utils/instrumentContext.js.map +1 -0
  9. package/build/cjs/workflows.js +2 -2
  10. package/build/cjs/workflows.js.map +1 -1
  11. package/build/cjs/wrapMethodWithSentry.js +143 -0
  12. package/build/cjs/wrapMethodWithSentry.js.map +1 -0
  13. package/build/esm/durableobject.js +4 -128
  14. package/build/esm/durableobject.js.map +1 -1
  15. package/build/esm/handler.js +6 -6
  16. package/build/esm/handler.js.map +1 -1
  17. package/build/esm/instrumentations/instrumentDurableObjectStorage.js +50 -0
  18. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  19. package/build/esm/package.json +1 -1
  20. package/build/esm/utils/instrumentContext.js +101 -0
  21. package/build/esm/utils/instrumentContext.js.map +1 -0
  22. package/build/esm/workflows.js +2 -2
  23. package/build/esm/workflows.js.map +1 -1
  24. package/build/esm/wrapMethodWithSentry.js +141 -0
  25. package/build/esm/wrapMethodWithSentry.js.map +1 -0
  26. package/build/types/durableobject.d.ts.map +1 -1
  27. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts +12 -0
  28. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -0
  29. package/build/types/utils/instrumentContext.d.ts +16 -0
  30. package/build/types/utils/instrumentContext.d.ts.map +1 -0
  31. package/build/types/wrapMethodWithSentry.d.ts +21 -0
  32. package/build/types/wrapMethodWithSentry.d.ts.map +1 -0
  33. package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +12 -0
  34. package/build/types-ts3.8/utils/instrumentContext.d.ts +16 -0
  35. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +21 -0
  36. package/package.json +3 -4
  37. package/build/cjs/utils/copyExecutionContext.js +0 -69
  38. package/build/cjs/utils/copyExecutionContext.js.map +0 -1
  39. package/build/esm/utils/copyExecutionContext.js +0 -67
  40. package/build/esm/utils/copyExecutionContext.js.map +0 -1
  41. package/build/types/utils/copyExecutionContext.d.ts +0 -11
  42. package/build/types/utils/copyExecutionContext.d.ts.map +0 -1
  43. package/build/types-ts3.8/utils/copyExecutionContext.d.ts +0 -11
@@ -1,67 +0,0 @@
1
- /**
2
- * Creates a new copy of the given execution context, optionally overriding methods.
3
- *
4
- * @param {ContextType|void} ctx - The execution context to be copied. Can be of type `ContextType` or `void`.
5
- * @return {ContextType|void} A new execution context with the same properties and overridden methods if applicable.
6
- */
7
- function copyExecutionContext(ctx) {
8
- if (!ctx) return ctx;
9
-
10
- const overrides = new Map();
11
- const contextPrototype = Object.getPrototypeOf(ctx);
12
- const prototypeMethodNames = Object.getOwnPropertyNames(contextPrototype) ;
13
- const ownPropertyNames = Object.getOwnPropertyNames(ctx) ;
14
- const instrumented = new Set(['constructor']);
15
- const descriptors = [...ownPropertyNames, ...prototypeMethodNames].reduce((prevDescriptors, methodName) => {
16
- if (instrumented.has(methodName)) return prevDescriptors;
17
- if (typeof ctx[methodName] !== 'function') return prevDescriptors;
18
- instrumented.add(methodName);
19
- const overridableDescriptor = makeOverridableDescriptor(overrides, ctx, methodName);
20
- return {
21
- ...prevDescriptors,
22
- [methodName]: overridableDescriptor,
23
- };
24
- }, {});
25
-
26
- return Object.create(ctx, descriptors);
27
- }
28
-
29
- /**
30
- * Creates a property descriptor that allows overriding of a method on the given context object.
31
- *
32
- * This descriptor supports property overriding with functions only. It delegates method calls to
33
- * the provided store if an override exists or to the original method on the context otherwise.
34
- *
35
- * @param {OverridesStore<ContextType>} store - The storage for overridden methods specific to the context type.
36
- * @param {ContextType} ctx - The context object that contains the method to be overridden.
37
- * @param {keyof ContextType} method - The method on the context object to create the overridable descriptor for.
38
- * @return {PropertyDescriptor} A property descriptor enabling the overriding of the specified method.
39
- */
40
- function makeOverridableDescriptor(
41
- store,
42
- ctx,
43
- method,
44
- ) {
45
- return {
46
- configurable: true,
47
- enumerable: true,
48
- set: newValue => {
49
- if (typeof newValue == 'function') {
50
- store.set(method, newValue);
51
- return;
52
- }
53
- Reflect.set(ctx, method, newValue);
54
- },
55
-
56
- get: () => {
57
- if (store.has(method)) return store.get(method);
58
- const methodFunction = Reflect.get(ctx, method);
59
- if (typeof methodFunction !== 'function') return methodFunction;
60
- // We should do bind() to make sure that the method is bound to the context object - otherwise it will not work
61
- return methodFunction.bind(ctx);
62
- },
63
- };
64
- }
65
-
66
- export { copyExecutionContext };
67
- //# sourceMappingURL=copyExecutionContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copyExecutionContext.js","sources":["../../../src/utils/copyExecutionContext.ts"],"sourcesContent":["import { type DurableObjectState, type ExecutionContext } from '@cloudflare/workers-types';\n\ntype ContextType = ExecutionContext | DurableObjectState;\ntype OverridesStore<T extends ContextType> = Map<keyof T, (...args: unknown[]) => unknown>;\n\n/**\n * Creates a new copy of the given execution context, optionally overriding methods.\n *\n * @param {ContextType|void} ctx - The execution context to be copied. Can be of type `ContextType` or `void`.\n * @return {ContextType|void} A new execution context with the same properties and overridden methods if applicable.\n */\nexport function copyExecutionContext<T extends ContextType>(ctx: T): T {\n if (!ctx) return ctx;\n\n const overrides: OverridesStore<T> = new Map();\n const contextPrototype = Object.getPrototypeOf(ctx);\n const prototypeMethodNames = Object.getOwnPropertyNames(contextPrototype) as unknown as (keyof T)[];\n const ownPropertyNames = Object.getOwnPropertyNames(ctx) as unknown as (keyof T)[];\n const instrumented = new Set<unknown>(['constructor']);\n const descriptors = [...ownPropertyNames, ...prototypeMethodNames].reduce((prevDescriptors, methodName) => {\n if (instrumented.has(methodName)) return prevDescriptors;\n if (typeof ctx[methodName] !== 'function') return prevDescriptors;\n instrumented.add(methodName);\n const overridableDescriptor = makeOverridableDescriptor(overrides, ctx, methodName);\n return {\n ...prevDescriptors,\n [methodName]: overridableDescriptor,\n };\n }, {});\n\n return Object.create(ctx, descriptors);\n}\n\n/**\n * Creates a property descriptor that allows overriding of a method on the given context object.\n *\n * This descriptor supports property overriding with functions only. It delegates method calls to\n * the provided store if an override exists or to the original method on the context otherwise.\n *\n * @param {OverridesStore<ContextType>} store - The storage for overridden methods specific to the context type.\n * @param {ContextType} ctx - The context object that contains the method to be overridden.\n * @param {keyof ContextType} method - The method on the context object to create the overridable descriptor for.\n * @return {PropertyDescriptor} A property descriptor enabling the overriding of the specified method.\n */\nfunction makeOverridableDescriptor<T extends ContextType>(\n store: OverridesStore<T>,\n ctx: T,\n method: keyof T,\n): PropertyDescriptor {\n return {\n configurable: true,\n enumerable: true,\n set: newValue => {\n if (typeof newValue == 'function') {\n store.set(method, newValue);\n return;\n }\n Reflect.set(ctx, method, newValue);\n },\n\n get: () => {\n if (store.has(method)) return store.get(method);\n const methodFunction = Reflect.get(ctx, method);\n if (typeof methodFunction !== 'function') return methodFunction;\n // We should do bind() to make sure that the method is bound to the context object - otherwise it will not work\n return methodFunction.bind(ctx);\n },\n };\n}\n"],"names":[],"mappings":"AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAwB,GAAG,EAAQ;AACvE,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG;;AAEtB,EAAE,MAAM,SAAS,GAAsB,IAAI,GAAG,EAAE;AAChD,EAAE,MAAM,mBAAmB,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC;AACrD,EAAE,MAAM,uBAAuB,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAA;AAC1E,EAAE,MAAM,mBAAmB,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAA;AACzD,EAAE,MAAM,e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,CAAC,GAAG,CAAC,MAAM,CAAC;AACrD,MAAM,MAAM,cAAA,GAAiB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;AACrD,MAAM,IAAI,OAAO,cAAA,KAAmB,UAAU,EAAE,OAAO,cAAc;AACrE;AACA,MAAM,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;AACrC,IAAI,CAAC;AACL,GAAG;AACH;;;;"}
@@ -1,11 +0,0 @@
1
- import { type DurableObjectState, type ExecutionContext } from '@cloudflare/workers-types';
2
- type ContextType = ExecutionContext | DurableObjectState;
3
- /**
4
- * Creates a new copy of the given execution context, optionally overriding methods.
5
- *
6
- * @param {ContextType|void} ctx - The execution context to be copied. Can be of type `ContextType` or `void`.
7
- * @return {ContextType|void} A new execution context with the same properties and overridden methods if applicable.
8
- */
9
- export declare function copyExecutionContext<T extends ContextType>(ctx: T): T;
10
- export {};
11
- //# sourceMappingURL=copyExecutionContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copyExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/utils/copyExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,KAAK,WAAW,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAGzD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAoBrE"}
@@ -1,11 +0,0 @@
1
- import { DurableObjectState, ExecutionContext } from '@cloudflare/workers-types';
2
- type ContextType = ExecutionContext | DurableObjectState;
3
- /**
4
- * Creates a new copy of the given execution context, optionally overriding methods.
5
- *
6
- * @param {ContextType|void} ctx - The execution context to be copied. Can be of type `ContextType` or `void`.
7
- * @return {ContextType|void} A new execution context with the same properties and overridden methods if applicable.
8
- */
9
- export declare function copyExecutionContext<T extends ContextType>(ctx: T): T;
10
- export {};
11
- //# sourceMappingURL=copyExecutionContext.d.ts.map