@arcadia-eternity/content-sdk 4.4.0 → 4.4.2

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,39 +1,6 @@
1
- export interface EnvironmentRules {
2
- schemaVersion: 1;
3
- tier?: string;
4
- allow?: {
5
- species?: string[];
6
- skills?: string[];
7
- marks?: string[];
8
- };
9
- deny?: {
10
- species?: string[];
11
- skills?: string[];
12
- marks?: string[];
13
- };
14
- team?: {
15
- minSize?: number;
16
- maxSize?: number;
17
- uniqueSpecies?: boolean;
18
- };
19
- }
20
- export interface EnvironmentDocument {
21
- schemaVersion: 2;
22
- id: string;
23
- name: string;
24
- packages: Record<string, string>;
25
- sources: string[];
26
- disabled?: {
27
- packages: Record<string, string>;
28
- sources: string[];
29
- };
30
- rules: EnvironmentRules;
31
- requires: {
32
- engine?: string;
33
- sdk?: string;
34
- capabilities?: string[];
35
- };
36
- }
1
+ import { type EnvironmentDocumentV2 } from './debug-environments.js';
2
+ export type { EnvironmentRules } from './debug-environments.js';
3
+ export type EnvironmentDocument = EnvironmentDocumentV2;
37
4
  export interface EnvironmentDraft {
38
5
  document: EnvironmentDocument;
39
6
  revision: string;
@@ -1,5 +1,26 @@
1
1
  import { type AuthorWorkspace } from './workspace.js';
2
2
  import { z } from 'zod';
3
+ /** Portable rule data. Runtime consumers must explicitly support every declared capability. */
4
+ export declare const EnvironmentRulesSchema: z.ZodObject<{
5
+ schemaVersion: z.ZodLiteral<1>;
6
+ tier: z.ZodOptional<z.ZodString>;
7
+ allow: z.ZodOptional<z.ZodObject<{
8
+ species: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
+ marks: z.ZodOptional<z.ZodArray<z.ZodString>>;
11
+ }, z.core.$strict>>;
12
+ deny: z.ZodOptional<z.ZodObject<{
13
+ species: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ marks: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
+ }, z.core.$strict>>;
17
+ team: z.ZodOptional<z.ZodObject<{
18
+ minSize: z.ZodOptional<z.ZodNumber>;
19
+ maxSize: z.ZodOptional<z.ZodNumber>;
20
+ uniqueSpecies: z.ZodOptional<z.ZodBoolean>;
21
+ }, z.core.$strict>>;
22
+ }, z.core.$strict>;
23
+ export type EnvironmentRules = z.infer<typeof EnvironmentRulesSchema>;
3
24
  export declare const EnvironmentDocumentV2Schema: z.ZodObject<{
4
25
  id: z.ZodString;
5
26
  name: z.ZodString;
@@ -42,7 +42,7 @@ const contentSelection = z
42
42
  })
43
43
  .strict();
44
44
  /** Portable rule data. Runtime consumers must explicitly support every declared capability. */
45
- const EnvironmentRulesSchema = z
45
+ export const EnvironmentRulesSchema = z
46
46
  .object({
47
47
  schemaVersion: z.literal(1),
48
48
  tier: z.string().regex(idPattern).optional(),
@@ -4,7 +4,7 @@ import { mkdir, mkdtemp, readFile, rm, writeFile, cp, symlink } from 'node:fs/pr
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join, resolve, dirname } from 'node:path';
6
6
  import { promisify } from 'node:util';
7
- import { emptyNpmContentHost, prepareNpmProject, resolveNpmInvocation } from '@arcadia-eternity/pack-loader/node';
7
+ import { emptyNpmContentHost, parseNpmPackOutput, prepareNpmProject, resolveNpmInvocation, } from '@arcadia-eternity/pack-loader/node';
8
8
  import { AuthorWorkspace } from './workspace.js';
9
9
  import { ProjectTeams, playersFromTeams } from './project-teams.js';
10
10
  import { createHash } from 'node:crypto';
@@ -13,6 +13,11 @@ import { assertEnvironmentRequirements, validateEnvironmentRules } from './envir
13
13
  import { siblingModulePath } from './module-path.js';
14
14
  import { errorCode } from './types.js';
15
15
  const exec = promisify(execFile);
16
+ function requirePackedInfo(entry) {
17
+ if (!entry?.shasum)
18
+ throw new Error('ENVIRONMENT_PACK_INVALID');
19
+ return { ...entry, shasum: entry.shasum };
20
+ }
16
21
  async function npm(args, options) {
17
22
  const invocation = await resolveNpmInvocation(args);
18
23
  return exec(invocation.file, invocation.args, options);
@@ -64,7 +69,7 @@ export async function prepareBattleEnvironment(root = process.cwd(), { offline =
64
69
  const result = await npm(['pack', '--json', '--ignore-scripts', '--pack-destination', temporary, ...cacheArgs], {
65
70
  cwd: root,
66
71
  });
67
- const packed = JSON.parse(String(result.stdout))[0];
72
+ const packed = requirePackedInfo(parseNpmPackOutput(String(result.stdout))[0]);
68
73
  const files = packed.files.map(file => file.path);
69
74
  assert.ok(files.includes(manifest.arcadia.content));
70
75
  if (manifest.arcadia.effects)
@@ -104,7 +109,7 @@ export async function prepareBattleEnvironment(root = process.cwd(), { offline =
104
109
  if (metadata.name !== name)
105
110
  throw new Error(`ENVIRONMENT_SOURCE_IDENTITY: ${name}`);
106
111
  await exec(process.execPath, [siblingModulePath('cli'), 'build'], { cwd: captured });
107
- const info = JSON.parse(String((await npm(['pack', '--json', '--ignore-scripts', ...cacheArgs], { cwd: captured })).stdout))[0];
112
+ const info = requirePackedInfo(parseNpmPackOutput(String((await npm(['pack', '--json', '--ignore-scripts', ...cacheArgs], { cwd: captured })).stdout))[0]);
108
113
  if (info.files.some(file => /^(?:debug|test|scripts|node_modules|\.arcadia|\.github)\//.test(file.path)))
109
114
  throw new Error('ENVIRONMENT_PACKAGE_FILES');
110
115
  await addCandidate(captured, metadata, info);
@@ -1,10 +1,6 @@
1
+ /** Trusted author packaging: close the effect dependency graph without evaluating it.
2
+ * Only the staged package gains artifact metadata; the source manifest is never rewritten.
3
+ */
1
4
  export declare function packBuiltProject(directory?: string, { cache }?: {
2
5
  cache?: string;
3
- }): Promise<{
4
- filename: string;
5
- files: Array<{
6
- path: string;
7
- }>;
8
- integrity?: string;
9
- shasum?: string;
10
- }>;
6
+ }): Promise<import("@arcadia-eternity/pack-loader/node").NpmPackEntry>;
@@ -3,7 +3,7 @@ import { statSync } from 'node:fs';
3
3
  import { copyFile, lstat, mkdir, mkdtemp, readFile, realpath, rename, rm, writeFile } from 'node:fs/promises';
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
5
5
  import { promisify } from 'node:util';
6
- import { compileEffectModule, resolveNpmInvocation } from '@arcadia-eternity/pack-loader/node';
6
+ import { compileEffectModule, parseNpmPackOutput, resolveNpmInvocation } from '@arcadia-eternity/pack-loader/node';
7
7
  import { errorCode } from './types.js';
8
8
  const exec = promisify(execFile);
9
9
  const artifactFile = 'dist/arcadia-effects.json';
@@ -59,12 +59,15 @@ async function stagingRoot(root) {
59
59
  }
60
60
  return directory;
61
61
  }
62
+ /** Trusted author packaging: close the effect dependency graph without evaluating it.
63
+ * Only the staged package gains artifact metadata; the source manifest is never rewritten.
64
+ */
62
65
  export async function packBuiltProject(directory = process.cwd(), { cache } = {}) {
63
66
  const root = await realpath(resolve(directory));
64
67
  const manifestText = await readFile(join(root, 'package.json'), 'utf8');
65
68
  const manifest = JSON.parse(manifestText);
66
- const preview = JSON.parse(String((await npm(root, ['pack', '--dry-run', '--ignore-scripts', '--json'], cache)).stdout))[0];
67
- if (!Array.isArray(preview?.files) || preview.files.length > 50000)
69
+ const preview = parseNpmPackOutput(String((await npm(root, ['pack', '--dry-run', '--ignore-scripts', '--json'], cache)).stdout))[0];
70
+ if (!preview || preview.files.length > 50000)
68
71
  fail('npm returned an invalid package file list');
69
72
  const included = new Set(preview.files.map((file) => packagePath(file.path)));
70
73
  if (!included.has('package.json'))
@@ -95,9 +98,7 @@ export async function packBuiltProject(directory = process.cwd(), { cache } = {}
95
98
  (presentation.bindings?.length || presentation.resources?.length || Object.keys(presentation.locales ?? {}).length)) {
96
99
  if (manifest.arcadia?.presentation !== 'dist/presentation.json')
97
100
  fail('Set arcadia.presentation to dist/presentation.json before packing media/locales');
98
- required.push('dist/content.json', 'dist/presentation.json', ...(presentation.resources ?? [])
99
- .filter((resource) => resource.kind === 'file' && typeof resource.source === 'string')
100
- .map(resource => resource.source));
101
+ required.push('dist/content.json', 'dist/presentation.json', ...(presentation.resources ?? []).filter(resource => resource.kind === 'file').map(resource => resource.source));
101
102
  }
102
103
  for (const file of required)
103
104
  if (!included.has(file))
@@ -153,8 +154,8 @@ export async function packBuiltProject(directory = process.cwd(), { cache } = {}
153
154
  }
154
155
  staged.files = [...distributed];
155
156
  await writeFile(join(payload, 'package.json'), JSON.stringify(staged, null, 2) + '\n');
156
- const packed = JSON.parse(String((await npm(payload, ['pack', '--ignore-scripts', '--json', '--pack-destination', output], cache)).stdout))[0];
157
- if (!packed || typeof packed.filename !== 'string' || !Array.isArray(packed.files))
157
+ const packed = parseNpmPackOutput(String((await npm(payload, ['pack', '--ignore-scripts', '--json', '--pack-destination', output], cache)).stdout))[0];
158
+ if (!packed)
158
159
  fail('npm returned an invalid package receipt');
159
160
  packagePath(packed.filename);
160
161
  if (basename(packed.filename) !== packed.filename)
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@types/node": "26.6.6",
23
23
  "typescript": "6.0.3",
24
- "@arcadia-eternity/content-sdk": "4.4.0"
24
+ "@arcadia-eternity/content-sdk": "4.4.2"
25
25
  },
26
26
  "arcadia": {
27
27
  "formatVersion": 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcadia-eternity/content-sdk",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -53,9 +53,9 @@
53
53
  "yaml": "2.9.1",
54
54
  "yauzl": "3.4.0",
55
55
  "zod": "4.6.7",
56
- "@arcadia-eternity/battle": "4.4.0",
57
- "@arcadia-eternity/schema": "4.4.0",
58
- "@arcadia-eternity/pack-loader": "4.4.0"
56
+ "@arcadia-eternity/battle": "4.4.2",
57
+ "@arcadia-eternity/pack-loader": "4.4.2",
58
+ "@arcadia-eternity/schema": "4.4.2"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",