@prestack/thread 0.1.7 → 0.1.9

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 (34) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/dist/core/attach.js +40 -6
  3. package/dist/core/attach.ts +38 -6
  4. package/dist/core/descend.js +13 -17
  5. package/dist/core/descend.ts +13 -15
  6. package/dist/integrations/attach.js +5 -3
  7. package/dist/integrations/attach.ts +8 -4
  8. package/dist/integrations/cli.d.ts +2 -0
  9. package/dist/integrations/cli.js +55 -11
  10. package/dist/integrations/cli.ts +62 -11
  11. package/dist/integrations/disk.js +4 -3
  12. package/dist/integrations/disk.ts +4 -3
  13. package/dist/integrations/generators/vault.ts +0 -1
  14. package/dist/integrations/target.d.ts +1 -1
  15. package/dist/integrations/target.ts +1 -1
  16. package/dist/integrity/generators/gate.ts +1 -2
  17. package/dist/integrity/generators/publish.ts +0 -1
  18. package/dist/integrity/lint.js +0 -6
  19. package/dist/integrity/lint.ts +0 -10
  20. package/dist/integrity/slopnator.ts +1 -1
  21. package/dist/integrity/slopnators/sl_derived_drift.js +0 -2
  22. package/dist/integrity/slopnators/sl_derived_drift.ts +0 -3
  23. package/dist/integrity/slopnators/sl_unthreaded.js +0 -2
  24. package/dist/integrity/slopnators/sl_unthreaded.ts +0 -5
  25. package/dist/integrity/sweep.ts +0 -2
  26. package/dist/knowledge/generators/docsgen.ts +1 -1
  27. package/dist/operations/generators/capability.js +20 -9
  28. package/dist/operations/generators/capability.ts +19 -12
  29. package/dist/operations/generators/compile.js +41 -28
  30. package/dist/operations/generators/compile.ts +48 -33
  31. package/dist/operations/generators/permits.js +6 -3
  32. package/dist/operations/generators/permits.ts +7 -5
  33. package/dist/operations/generators/trial.ts +1 -1
  34. package/package.json +1 -1
@@ -1,8 +1,7 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from '../../integrations/disk.ts'
2
2
  import { valuesIn } from '../../core/rows.ts'
3
- import { dirname, resolve } from 'node:path'
3
+ import { resolve } from 'node:path'
4
4
  import { argv, stderr, stdout } from 'node:process'
5
- import { pathToFileURL } from 'node:url'
6
5
 
7
6
  import { exit } from '../../core/invoked.ts'
8
7
  import { PUBLIC_ROLE as PUBLIC } from '../../core/actor.ts'
@@ -81,6 +80,8 @@ if (open.length > 0) {
81
80
 
82
81
  const said = (held: unknown): string => JSON.stringify(held)
83
82
 
83
+ const used = new Set<readonly string[]>()
84
+
84
85
  function reads(one: Operand, grant: Grant): string {
85
86
  if ('value' in one) return said(one.value)
86
87
  if ('now' in one) return 'Date.now()'
@@ -106,6 +107,7 @@ function reads(one: Operand, grant: Grant): string {
106
107
  '" itself, or state the rule as an invariant where the rows are',
107
108
  )
108
109
  }
110
+ used.add(READS)
109
111
  return `at(resource, ${said(one.field)})`
110
112
  }
111
113
  stop(`\`${grant.id}\` states an operand this gate cannot read`)
@@ -119,6 +121,7 @@ function predicate(condition: Condition, grant: Grant): string {
119
121
  return condition.any.length === 0 ? 'false' : `(${condition.any.map((one) => predicate(one, grant)).join(' || ')})`
120
122
  }
121
123
  if ('not' in condition) return `(!${predicate(condition.not, grant)})`
124
+ used.add(COMPARES)
122
125
  return `held(${said(condition.op)}, ${reads(condition.is, grant)}, ${reads(condition.than, grant)})`
123
126
  }
124
127
 
@@ -127,6 +130,7 @@ function wears(grant: Grant): readonly string[] {
127
130
  const roles = grant.to?.roles
128
131
  if (roles !== undefined && !roles.includes(PUBLIC)) held.push(`some(actor.roles, ${said(roles)})`)
129
132
  if (grant.to?.entitlements !== undefined) held.push(`some(actor.entitlements, ${said(grant.to.entitlements)})`)
133
+ if (held.length > 0) used.add(WEARS)
130
134
  return held
131
135
  }
132
136
 
@@ -181,9 +185,7 @@ function permitting(): string {
181
185
  `import type { Actor } from '${runtime(PERMITS_AT, '../../core/actor.ts')}'`,
182
186
  "import type { Row } from '" + runtime(PERMITS_AT, '../../integrations/target.ts') + "'",
183
187
  '',
184
- ...(grants.some((one) => one.when !== undefined) ? [...READS, ''] : []),
185
- ...(grants.some((one) => one.to !== undefined) ? [...WEARS, ''] : []),
186
- ...(grants.some((one) => one.when !== undefined) ? [...COMPARES, ''] : []),
188
+ ...[READS, WEARS, COMPARES].filter((one) => used.has(one)).flatMap((one) => [...one, '']),
187
189
 
188
190
  'export function permits(actor: Actor, action: string, resource: Row | null): { allow: boolean; because?: string } {',
189
191
  ...(grants.length === 0 ? [' void actor', ' void resource'] : []),
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync, writeFileSync, type Answering, type Listed } from '../../integrations/disk.ts'
2
- import { dirname, resolve } from 'node:path'
2
+ import { resolve } from 'node:path'
3
3
  import { argv, stdout } from 'node:process'
4
4
  import { pathToFileURL } from 'node:url'
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prestack/thread",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",