@ankhorage/projects 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +17 -2
- package/dist/capabilities/index.d.ts +52 -0
- package/dist/capabilities/index.js +43 -0
- package/dist/features/projects/adapters/createProjectRepositoryFileSystemAsync.d.ts +13 -0
- package/dist/features/projects/adapters/createProjectRepositoryFileSystemAsync.js +161 -0
- package/dist/features/projects/application/projects.d.ts +10 -0
- package/dist/features/projects/application/projects.js +18 -0
- package/dist/features/projects/domain/createProject.d.ts +3 -0
- package/dist/features/projects/domain/createProject.js +15 -0
- package/dist/features/projects/domain/deriveProjectIdentity.d.ts +2 -0
- package/dist/features/projects/domain/deriveProjectIdentity.js +9 -0
- package/dist/features/projects/domain/updateProject.d.ts +3 -0
- package/dist/features/projects/domain/updateProject.js +13 -0
- package/dist/features/projects/ports/ProjectRepository.d.ts +8 -0
- package/dist/features/projects/ports/ProjectRepository.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/types/projects.d.ts +13 -0
- package/dist/types/projects.js +1 -0
- package/package.json +145 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ankhorage
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD013 MD033 -->
|
|
2
|
+
<!-- This file is generated by Paradox. Do not edit manually. -->
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
# @ankhorage/projects
|
|
5
|
+
|
|
6
|
+
        
|
|
7
|
+
|
|
8
|
+
Standalone project identity and repository actions.
|
|
9
|
+
|
|
10
|
+
## Generated documentation
|
|
11
|
+
|
|
12
|
+
- [Interactive documentation app](././paradox/index.html)
|
|
13
|
+
- [Public API reference](././paradox/exports.md)
|
|
14
|
+
- [Component registry](././paradox/components.md)
|
|
15
|
+
- [Architecture overview](././paradox/diagrams/architecture-overview.mmd)
|
|
16
|
+
- [Module relationships](././paradox/diagrams/module-relationships.mmd)
|
|
17
|
+
- [Export graph](././paradox/diagrams/export-graph.mmd)
|
|
18
|
+
- [createProjectRepositoryFileSystemAsync sequence](././paradox/diagrams/sequences/create-project-repository-file-system-async.mmd)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*** Publish the canonical descriptors for project repository operations. */
|
|
2
|
+
export declare const CAPABILITIES: readonly [{
|
|
3
|
+
readonly id: "projects.list";
|
|
4
|
+
readonly owner: "@ankhorage/projects";
|
|
5
|
+
readonly access: readonly ["read"];
|
|
6
|
+
readonly binding: {
|
|
7
|
+
readonly kind: "storage";
|
|
8
|
+
readonly bindableAs: readonly ["target"];
|
|
9
|
+
};
|
|
10
|
+
readonly label: "List projects";
|
|
11
|
+
readonly description: "List persisted project identities.";
|
|
12
|
+
}, {
|
|
13
|
+
readonly id: "projects.read";
|
|
14
|
+
readonly owner: "@ankhorage/projects";
|
|
15
|
+
readonly access: readonly ["read"];
|
|
16
|
+
readonly binding: {
|
|
17
|
+
readonly kind: "storage";
|
|
18
|
+
readonly bindableAs: readonly ["target"];
|
|
19
|
+
};
|
|
20
|
+
readonly label: "Read project";
|
|
21
|
+
readonly description: "Read one persisted project by identity.";
|
|
22
|
+
}, {
|
|
23
|
+
readonly id: "projects.create";
|
|
24
|
+
readonly owner: "@ankhorage/projects";
|
|
25
|
+
readonly access: readonly ["write"];
|
|
26
|
+
readonly binding: {
|
|
27
|
+
readonly kind: "storage";
|
|
28
|
+
readonly bindableAs: readonly ["target"];
|
|
29
|
+
};
|
|
30
|
+
readonly label: "Create project";
|
|
31
|
+
readonly description: "Create one persisted project with a canonical identity.";
|
|
32
|
+
}, {
|
|
33
|
+
readonly id: "projects.update";
|
|
34
|
+
readonly owner: "@ankhorage/projects";
|
|
35
|
+
readonly access: readonly ["write"];
|
|
36
|
+
readonly binding: {
|
|
37
|
+
readonly kind: "storage";
|
|
38
|
+
readonly bindableAs: readonly ["target"];
|
|
39
|
+
};
|
|
40
|
+
readonly label: "Update project";
|
|
41
|
+
readonly description: "Update one existing persisted project.";
|
|
42
|
+
}, {
|
|
43
|
+
readonly id: "projects.delete";
|
|
44
|
+
readonly owner: "@ankhorage/projects";
|
|
45
|
+
readonly access: readonly ["write"];
|
|
46
|
+
readonly binding: {
|
|
47
|
+
readonly kind: "storage";
|
|
48
|
+
readonly bindableAs: readonly ["target"];
|
|
49
|
+
};
|
|
50
|
+
readonly label: "Delete project";
|
|
51
|
+
readonly description: "Delete one persisted project by identity.";
|
|
52
|
+
}];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*** Publish the canonical descriptors for project repository operations. */
|
|
2
|
+
export const CAPABILITIES = [
|
|
3
|
+
{
|
|
4
|
+
id: 'projects.list',
|
|
5
|
+
owner: '@ankhorage/projects',
|
|
6
|
+
access: ['read'],
|
|
7
|
+
binding: { kind: 'storage', bindableAs: ['target'] },
|
|
8
|
+
label: 'List projects',
|
|
9
|
+
description: 'List persisted project identities.',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: 'projects.read',
|
|
13
|
+
owner: '@ankhorage/projects',
|
|
14
|
+
access: ['read'],
|
|
15
|
+
binding: { kind: 'storage', bindableAs: ['target'] },
|
|
16
|
+
label: 'Read project',
|
|
17
|
+
description: 'Read one persisted project by identity.',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'projects.create',
|
|
21
|
+
owner: '@ankhorage/projects',
|
|
22
|
+
access: ['write'],
|
|
23
|
+
binding: { kind: 'storage', bindableAs: ['target'] },
|
|
24
|
+
label: 'Create project',
|
|
25
|
+
description: 'Create one persisted project with a canonical identity.',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'projects.update',
|
|
29
|
+
owner: '@ankhorage/projects',
|
|
30
|
+
access: ['write'],
|
|
31
|
+
binding: { kind: 'storage', bindableAs: ['target'] },
|
|
32
|
+
label: 'Update project',
|
|
33
|
+
description: 'Update one existing persisted project.',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'projects.delete',
|
|
37
|
+
owner: '@ankhorage/projects',
|
|
38
|
+
access: ['write'],
|
|
39
|
+
binding: { kind: 'storage', bindableAs: ['target'] },
|
|
40
|
+
label: 'Delete project',
|
|
41
|
+
description: 'Delete one persisted project by identity.',
|
|
42
|
+
},
|
|
43
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProjectRepository } from '../ports/ProjectRepository.js';
|
|
2
|
+
type FileSystemProjectRepositoryOptions = Readonly<{
|
|
3
|
+
directory: string;
|
|
4
|
+
}>;
|
|
5
|
+
/***
|
|
6
|
+
* Create a path-isolated filesystem implementation of the project repository port.
|
|
7
|
+
*
|
|
8
|
+
* The keyed mutex coordinates mutations only through this adapter instance in one Node.js process.
|
|
9
|
+
* Assign each storage directory to one writer; coordinating separate adapter instances or processes
|
|
10
|
+
* requires external locking and is unsupported by this adapter.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createProjectRepositoryFileSystemAsync(options: FileSystemProjectRepositoryOptions): Promise<ProjectRepository>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { constants, link, mkdir, open, readdir, rename, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { createKeyedAsyncMutex } from '@ankhorage/utility/concurrency';
|
|
4
|
+
import { isRecord } from '@ankhorage/utility/object';
|
|
5
|
+
/***
|
|
6
|
+
* Create a path-isolated filesystem implementation of the project repository port.
|
|
7
|
+
*
|
|
8
|
+
* The keyed mutex coordinates mutations only through this adapter instance in one Node.js process.
|
|
9
|
+
* Assign each storage directory to one writer; coordinating separate adapter instances or processes
|
|
10
|
+
* requires external locking and is unsupported by this adapter.
|
|
11
|
+
*/
|
|
12
|
+
export async function createProjectRepositoryFileSystemAsync(options) {
|
|
13
|
+
const directory = join(options.directory, 'projects');
|
|
14
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
15
|
+
await assertStorageDirectoryAsync(directory);
|
|
16
|
+
const mutations = createKeyedAsyncMutex({
|
|
17
|
+
createBusyError: (id) => new Error(`Project identity '${id}' is busy.`),
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
listAsync: async () => {
|
|
21
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
22
|
+
const projects = await Promise.all(entries
|
|
23
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith('.json'))
|
|
24
|
+
.map(async (entry) => readProjectAsync(directory, entry.name)));
|
|
25
|
+
return projects
|
|
26
|
+
.filter((project) => project !== null)
|
|
27
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
28
|
+
},
|
|
29
|
+
readAsync: async (id) => readProjectAsync(directory, projectFileName(id)),
|
|
30
|
+
createAsync: async (project) => mutations.run(project.id, async () => writeProjectAsync(directory, project, true)),
|
|
31
|
+
updateAsync: async (id, update) => mutations.run(id, async () => {
|
|
32
|
+
const project = await readProjectAsync(directory, projectFileName(id));
|
|
33
|
+
if (project === null)
|
|
34
|
+
return null;
|
|
35
|
+
const updated = update(project);
|
|
36
|
+
if (updated.id !== id)
|
|
37
|
+
throw new Error('Project update cannot change identity.');
|
|
38
|
+
await writeProjectAsync(directory, updated, false);
|
|
39
|
+
return updated;
|
|
40
|
+
}),
|
|
41
|
+
deleteAsync: async (id) => mutations.run(id, async () => deleteProjectAsync(directory, id)),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/*** Confirm that the storage directory itself cannot be a symlink. */
|
|
45
|
+
async function assertStorageDirectoryAsync(directory) {
|
|
46
|
+
const handle = await open(directory, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
47
|
+
try {
|
|
48
|
+
if (!(await handle.stat()).isDirectory()) {
|
|
49
|
+
throw new Error('Project storage must be a directory.');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
await handle.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/*** Read a regular, schema-valid project file through a no-follow file handle. */
|
|
57
|
+
async function readProjectAsync(directory, fileName, expectedFileName = fileName) {
|
|
58
|
+
const path = join(directory, fileName);
|
|
59
|
+
let handle;
|
|
60
|
+
try {
|
|
61
|
+
handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
62
|
+
if (!(await handle.stat()).isFile())
|
|
63
|
+
throw new Error(`Project storage entry '${fileName}' must be a regular file.`);
|
|
64
|
+
const stored = JSON.parse(await handle.readFile({ encoding: 'utf8' }));
|
|
65
|
+
if (!isStoredProject(stored) || projectFileName(stored.project.id) !== expectedFileName) {
|
|
66
|
+
throw new Error(`Project storage entry '${fileName}' is invalid.`);
|
|
67
|
+
}
|
|
68
|
+
return stored.project;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (isMissingFileError(error))
|
|
72
|
+
return null;
|
|
73
|
+
if (isSymlinkError(error)) {
|
|
74
|
+
throw new Error(`Project storage entry '${fileName}' must be a regular file.`, {
|
|
75
|
+
cause: error,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
await handle?.close();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/*** Atomically create or replace a project file without exposing a partial document. */
|
|
85
|
+
async function writeProjectAsync(directory, project, createOnly) {
|
|
86
|
+
const fileName = projectFileName(project.id);
|
|
87
|
+
const target = join(directory, fileName);
|
|
88
|
+
const temporary = join(directory, `.${fileName}.${crypto.randomUUID()}.tmp`);
|
|
89
|
+
await writeTemporaryProjectAsync(temporary, project);
|
|
90
|
+
try {
|
|
91
|
+
if (createOnly)
|
|
92
|
+
await link(temporary, target);
|
|
93
|
+
else
|
|
94
|
+
await rename(temporary, target);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
await rm(temporary, { force: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/*** Write a private temporary project file without following or replacing an existing entry. */
|
|
101
|
+
async function writeTemporaryProjectAsync(temporary, project) {
|
|
102
|
+
const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
103
|
+
try {
|
|
104
|
+
await handle.writeFile(JSON.stringify({ version: 1, project }), 'utf8');
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
await handle.close();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/*** Atomically detach a project, restoring it when validation or deletion cannot complete. */
|
|
111
|
+
async function deleteProjectAsync(directory, id) {
|
|
112
|
+
const fileName = projectFileName(id);
|
|
113
|
+
const target = join(directory, fileName);
|
|
114
|
+
const temporary = join(directory, `.${fileName}.${crypto.randomUUID()}.delete`);
|
|
115
|
+
try {
|
|
116
|
+
await rename(target, temporary);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (isMissingFileError(error))
|
|
120
|
+
return null;
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const project = await readProjectAsync(directory, temporary.slice(directory.length + 1), fileName);
|
|
125
|
+
if (project === null)
|
|
126
|
+
throw new Error(`Project storage entry '${fileName}' disappeared.`);
|
|
127
|
+
await rm(temporary);
|
|
128
|
+
return project;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
await rename(temporary, target);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/*** Convert only canonical project identities into a local storage filename. */
|
|
136
|
+
function projectFileName(id) {
|
|
137
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(id)) {
|
|
138
|
+
throw new Error('Project identity is invalid.');
|
|
139
|
+
}
|
|
140
|
+
return `${id}.json`;
|
|
141
|
+
}
|
|
142
|
+
/*** Verify a parsed storage document before it enters the application. */
|
|
143
|
+
function isStoredProject(value) {
|
|
144
|
+
if (!isRecord(value))
|
|
145
|
+
return false;
|
|
146
|
+
const { project } = value;
|
|
147
|
+
return (value.version === 1 &&
|
|
148
|
+
isRecord(project) &&
|
|
149
|
+
typeof project.id === 'string' &&
|
|
150
|
+
typeof project.name === 'string' &&
|
|
151
|
+
typeof project.createdAt === 'string' &&
|
|
152
|
+
typeof project.updatedAt === 'string');
|
|
153
|
+
}
|
|
154
|
+
/*** Identify the missing-file condition that represents an absent project. */
|
|
155
|
+
function isMissingFileError(error) {
|
|
156
|
+
return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
|
|
157
|
+
}
|
|
158
|
+
/*** Identify no-follow failures caused by a symbolic link at the opened path. */
|
|
159
|
+
function isSymlinkError(error) {
|
|
160
|
+
return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ELOOP';
|
|
161
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreateProjectInput, Project, UpdateProjectInput } from '../../../types/projects.js';
|
|
2
|
+
import type { ProjectRepository } from '../ports/ProjectRepository.js';
|
|
3
|
+
/*** Expose the project repository actions through an explicit port. */
|
|
4
|
+
export declare const projects: {
|
|
5
|
+
list: (repository: ProjectRepository) => Promise<readonly Project[]>;
|
|
6
|
+
read: (repository: ProjectRepository, id: string) => Promise<Project | null>;
|
|
7
|
+
create: (repository: ProjectRepository, input: CreateProjectInput, now?: Date) => Promise<Project>;
|
|
8
|
+
update: (repository: ProjectRepository, input: UpdateProjectInput, now?: Date) => Promise<Project | null>;
|
|
9
|
+
delete: (repository: ProjectRepository, id: string) => Promise<Project | null>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createProject } from '../domain/createProject.js';
|
|
2
|
+
import { updateProject } from '../domain/updateProject.js';
|
|
3
|
+
/*** Expose the project repository actions through an explicit port. */
|
|
4
|
+
export const projects = {
|
|
5
|
+
list: async (repository) => repository.listAsync(),
|
|
6
|
+
read: async (repository, id) => repository.readAsync(id),
|
|
7
|
+
create: async (repository, input, now = new Date()) => {
|
|
8
|
+
const project = createProject(input, now);
|
|
9
|
+
const existing = await repository.listAsync();
|
|
10
|
+
if (existing.some((candidate) => candidate.id === project.id)) {
|
|
11
|
+
throw new Error(`Project identity '${project.id}' already exists.`);
|
|
12
|
+
}
|
|
13
|
+
await repository.createAsync(project);
|
|
14
|
+
return project;
|
|
15
|
+
},
|
|
16
|
+
update: async (repository, input, now = new Date()) => repository.updateAsync(input.id, (project) => updateProject(project, input, now)),
|
|
17
|
+
delete: async (repository, id) => repository.deleteAsync(id),
|
|
18
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { deriveProjectIdentity } from './deriveProjectIdentity.js';
|
|
2
|
+
/*** Create a valid project with an immutable identity. */
|
|
3
|
+
export function createProject(input, now) {
|
|
4
|
+
const name = normalizeProjectName(input.name);
|
|
5
|
+
const timestamp = now.toISOString();
|
|
6
|
+
return { id: deriveProjectIdentity(name), name, createdAt: timestamp, updatedAt: timestamp };
|
|
7
|
+
}
|
|
8
|
+
/*** Normalize a project name at the domain boundary. */
|
|
9
|
+
function normalizeProjectName(name) {
|
|
10
|
+
const normalized = name.trim();
|
|
11
|
+
if (normalized.length === 0 || normalized.length > 120) {
|
|
12
|
+
throw new Error('A project name must contain between 1 and 120 characters.');
|
|
13
|
+
}
|
|
14
|
+
return normalized;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { slugifyAscii } from '@ankhorage/utility/string';
|
|
2
|
+
/*** Derive the canonical path-safe project identity from a project name. */
|
|
3
|
+
export function deriveProjectIdentity(name) {
|
|
4
|
+
const id = slugifyAscii(name);
|
|
5
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(id)) {
|
|
6
|
+
throw new Error('A project name must derive a lowercase hyphenated identity.');
|
|
7
|
+
}
|
|
8
|
+
return id;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*** Apply a valid mutable project change while preserving identity. */
|
|
2
|
+
export function updateProject(project, input, now) {
|
|
3
|
+
const name = normalizeProjectName(input.name);
|
|
4
|
+
return { ...project, name, updatedAt: now.toISOString() };
|
|
5
|
+
}
|
|
6
|
+
/*** Normalize a project name at the domain boundary. */
|
|
7
|
+
function normalizeProjectName(name) {
|
|
8
|
+
const normalized = name.trim();
|
|
9
|
+
if (normalized.length === 0 || normalized.length > 120) {
|
|
10
|
+
throw new Error('A project name must contain between 1 and 120 characters.');
|
|
11
|
+
}
|
|
12
|
+
return normalized;
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Project } from '../../../types/projects.js';
|
|
2
|
+
export interface ProjectRepository {
|
|
3
|
+
listAsync(): Promise<readonly Project[]>;
|
|
4
|
+
readAsync(id: string): Promise<Project | null>;
|
|
5
|
+
createAsync(project: Project): Promise<void>;
|
|
6
|
+
updateAsync(id: string, update: (project: Project) => Project): Promise<Project | null>;
|
|
7
|
+
deleteAsync(id: string): Promise<Project | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createProjectRepositoryFileSystemAsync } from './features/projects/adapters/createProjectRepositoryFileSystemAsync.js';
|
|
2
|
+
export { projects } from './features/projects/application/projects.js';
|
|
3
|
+
export type { ProjectRepository } from './features/projects/ports/ProjectRepository.js';
|
|
4
|
+
export type { CreateProjectInput, Project, UpdateProjectInput } from './types/projects.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Project = Readonly<{
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
createdAt: string;
|
|
5
|
+
updatedAt: string;
|
|
6
|
+
}>;
|
|
7
|
+
export type CreateProjectInput = Readonly<{
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type UpdateProjectInput = Readonly<{
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,147 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/projects",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone project identity and repository actions.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ankhorage",
|
|
7
|
+
"projects",
|
|
8
|
+
"persistence"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"homepage": "https://github.com/ankhorage/projects#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/ankhorage/projects/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/ankhorage/projects.git"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./capabilities": {
|
|
36
|
+
"types": "./dist/capabilities/index.d.ts",
|
|
37
|
+
"import": "./dist/capabilities/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"packageManager": "bun@1.4.2",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && bun x tsc -p tsconfig.build.json",
|
|
43
|
+
"check-types": "bun x tsc --noEmit -p tsconfig.json",
|
|
44
|
+
"typecheck": "bun run check-types",
|
|
45
|
+
"test": "bun test",
|
|
46
|
+
"lint": "ankhorage-eslint . --max-warnings=0",
|
|
47
|
+
"knip:check": "ankhorage-knip",
|
|
48
|
+
"format": "ankhorage-prettier --write .",
|
|
49
|
+
"format:check": "ankhorage-prettier --check .",
|
|
50
|
+
"changeset": "ankhorage-changeset",
|
|
51
|
+
"changeset:status": "ankhorage-changeset status --since=origin/main",
|
|
52
|
+
"docs": "paradox",
|
|
53
|
+
"lint:fix": "ankhorage-eslint . --fix --max-warnings=0",
|
|
54
|
+
"version-packages": "ankhorage-changeset version"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@ankhorage/devtools": "^2.5.0",
|
|
58
|
+
"@ankhorage/paradox": "^0.3.6",
|
|
59
|
+
"@types/bun": "^1.4.2",
|
|
60
|
+
"@types/node": "^26.6.6",
|
|
61
|
+
"typescript": "~6.0.3"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@ankhorage/contracts": "^26.4.0",
|
|
65
|
+
"@ankhorage/utility": "^1.10.0"
|
|
66
|
+
},
|
|
67
|
+
"ankh": {
|
|
68
|
+
"category": "projects",
|
|
69
|
+
"capabilities": [
|
|
70
|
+
{
|
|
71
|
+
"id": "projects.list",
|
|
72
|
+
"owner": "@ankhorage/projects",
|
|
73
|
+
"access": [
|
|
74
|
+
"read"
|
|
75
|
+
],
|
|
76
|
+
"binding": {
|
|
77
|
+
"kind": "storage",
|
|
78
|
+
"bindableAs": [
|
|
79
|
+
"target"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"label": "List projects",
|
|
83
|
+
"description": "List persisted project identities."
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "projects.read",
|
|
87
|
+
"owner": "@ankhorage/projects",
|
|
88
|
+
"access": [
|
|
89
|
+
"read"
|
|
90
|
+
],
|
|
91
|
+
"binding": {
|
|
92
|
+
"kind": "storage",
|
|
93
|
+
"bindableAs": [
|
|
94
|
+
"target"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"label": "Read project",
|
|
98
|
+
"description": "Read one persisted project by identity."
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "projects.create",
|
|
102
|
+
"owner": "@ankhorage/projects",
|
|
103
|
+
"access": [
|
|
104
|
+
"write"
|
|
105
|
+
],
|
|
106
|
+
"binding": {
|
|
107
|
+
"kind": "storage",
|
|
108
|
+
"bindableAs": [
|
|
109
|
+
"target"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"label": "Create project",
|
|
113
|
+
"description": "Create one persisted project with a canonical identity."
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"id": "projects.update",
|
|
117
|
+
"owner": "@ankhorage/projects",
|
|
118
|
+
"access": [
|
|
119
|
+
"write"
|
|
120
|
+
],
|
|
121
|
+
"binding": {
|
|
122
|
+
"kind": "storage",
|
|
123
|
+
"bindableAs": [
|
|
124
|
+
"target"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
"label": "Update project",
|
|
128
|
+
"description": "Update one existing persisted project."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "projects.delete",
|
|
132
|
+
"owner": "@ankhorage/projects",
|
|
133
|
+
"access": [
|
|
134
|
+
"write"
|
|
135
|
+
],
|
|
136
|
+
"binding": {
|
|
137
|
+
"kind": "storage",
|
|
138
|
+
"bindableAs": [
|
|
139
|
+
"target"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"label": "Delete project",
|
|
143
|
+
"description": "Delete one persisted project by identity."
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
}
|