@orbit-app/functions 0.10.0 → 0.11.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/README.md CHANGED
@@ -22,7 +22,7 @@ export default defineFunction({
22
22
  });
23
23
  ```
24
24
 
25
- A run reads and writes objects with the access of its person. An action run acts as its caller, and a delegate run as the member who signed it: it reads only what that person's app can read, and an object that it creates without `owner` belongs to that person. A webhook run, a schedule run and a delegate run that an event or a schedule signed act as the app: they read the objects that the app owns and the objects shared with the whole store. `orbit.app.objects` and `orbit.app.defineObjects()` call as the app, only within the `grants` of the function in `orbit.json`, such as `{ "kudos": ["create"] }`. The approval dialog shows each grant (0.10.0 and later; the doc `migrations/functions-caller-access` gives the move).
25
+ A run reads and writes objects with the access of its person. An action run acts as its caller, and a delegate run as the member who signed it: it reads only what that person's app can read, and an object that it creates without `owner` belongs to that person. A webhook run, a schedule run and a delegate run that an event or a schedule signed act as the app: they read the objects that the app owns and the objects shared with the whole store. `orbit.app.objects` and `orbit.app.defineObjects()` call as the app, only within the `grants` of the function in `orbit.json`, such as `{ "kudos": ["create"] }`. The approval dialog shows each grant (0.10.0 and later; the doc `migrations/functions-caller-access` gives the move). From 0.11.0, a typed `update` or `delete` as the app needs no `read` grant: Orbit checks the type (the doc `migrations/functions-app-writes`).
26
26
 
27
27
  `orbit.runOrg()` gives the org that the run acts in, in the shape of `getOrg()` of `@orbit-app/web`: the caller's org of an action, the signer's org of a delegate, else the org that owns the app. `orbit.appOrg()` gives the org that owns the app. `orbit.org()` is the same as `appOrg()` and goes in a later release (0.10.0 and later; the doc `migrations/functions-run-org` gives the move).
28
28
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type OperationTypes, type ObjectsApi, type ObjectsClient, type ObjectsOptions } from "@orbit-app/web";
2
- export { OrbitConnectionError, OrbitObjectError, type ObjectsApi, type ObjectsClient, type ObjectsOptions, type OperationTypes, type OrbitConnectionErrorCode, type RetryOptions, } from "@orbit-app/web";
2
+ export { OrbitConnectionError, OrbitObjectError, type ObjectsApi, type ObjectsClient, type ObjectsOptions, type OperationTypes, type OrbitConnectionErrorCode, type RetryOptions, type WriteOptions, } from "@orbit-app/web";
3
3
  export type ActionTrigger = {
4
4
  type: "action";
5
5
  };
package/dist/index.js CHANGED
@@ -171,15 +171,17 @@ function createOrbit(req) {
171
171
  });
172
172
  }
173
173
  const enc = encodeURIComponent;
174
+ const typeQuery = (options) => (options?.type === undefined ? "" : `?type=${enc(options.type)}`);
174
175
  const objectsAs = (asApp) => ({
175
176
  create: (input) => call("POST", "/v1/objects", input, objectError, asApp),
176
177
  get: (id) => call("GET", `/v1/objects/${enc(id)}`, undefined, objectError, asApp),
177
178
  getByHandle: (type, handle) => call("GET", `/v1/objects/by-handle/${enc(type)}/${enc(handle)}`, undefined, objectError, asApp),
178
179
  list: (input) => call("POST", "/v1/objects/query", input, objectError, asApp),
179
- update: (id, input) => call("PATCH", `/v1/objects/${enc(id)}`, input, objectError, asApp),
180
+ // ?type= makes the API check the type, so a typed write needs no read grant.
181
+ update: (id, input, options) => call("PATCH", `/v1/objects/${enc(id)}${typeQuery(options)}`, input, objectError, asApp),
180
182
  upsert: (type, handle, input = {}) => call("PUT", `/v1/objects/by-handle/${enc(type)}/${enc(handle)}`, input, objectError, asApp),
181
- delete: async (id) => {
182
- await call("DELETE", `/v1/objects/${enc(id)}`, undefined, objectError, asApp);
183
+ delete: async (id, options) => {
184
+ await call("DELETE", `/v1/objects/${enc(id)}${typeQuery(options)}`, undefined, objectError, asApp);
183
185
  },
184
186
  });
185
187
  const once = objectsAs(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-app/functions",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Write Orbit Functions: publisher code that runs in Orbit's sandbox as its caller or as the app.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@
19
19
  "prepack": "pnpm build"
20
20
  },
21
21
  "dependencies": {
22
- "@orbit-app/web": "^0.5.0"
22
+ "@orbit-app/web": "^0.6.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "^7.0.2",