@meridianjs/project 0.1.1 → 0.1.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.
package/dist/index.d.mts CHANGED
@@ -21,6 +21,12 @@ declare class ProjectModuleService extends ProjectModuleService_base {
21
21
  listMilestonesByProject(projectId: string): Promise<any[]>;
22
22
  /** List all statuses for a given project, ordered by position. */
23
23
  listStatusesByProject(projectId: string): Promise<any[]>;
24
+ /** Generate a random share token and set visibility to "public". */
25
+ generateShareToken(projectId: string): Promise<any>;
26
+ /** Remove the share token and set visibility back to "private". */
27
+ revokeShareToken(projectId: string): Promise<any>;
28
+ /** Find a project by share token. Returns null if not found or not public. */
29
+ retrieveProjectByShareToken(token: string): Promise<any | null>;
24
30
  /** Update position field for each status to match the provided orderedIds index. */
25
31
  reorderStatuses(projectId: string, orderedIds: string[]): Promise<void>;
26
32
  }
package/dist/index.d.ts CHANGED
@@ -21,6 +21,12 @@ declare class ProjectModuleService extends ProjectModuleService_base {
21
21
  listMilestonesByProject(projectId: string): Promise<any[]>;
22
22
  /** List all statuses for a given project, ordered by position. */
23
23
  listStatusesByProject(projectId: string): Promise<any[]>;
24
+ /** Generate a random share token and set visibility to "public". */
25
+ generateShareToken(projectId: string): Promise<any>;
26
+ /** Remove the share token and set visibility back to "private". */
27
+ revokeShareToken(projectId: string): Promise<any>;
28
+ /** Find a project by share token. Returns null if not found or not public. */
29
+ retrieveProjectByShareToken(token: string): Promise<any | null>;
24
30
  /** Update position field for each status to match the provided orderedIds index. */
25
31
  reorderStatuses(projectId: string, orderedIds: string[]): Promise<void>;
26
32
  }
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ var import_framework_utils7 = require("@meridianjs/framework-utils");
29
29
 
30
30
  // src/service.ts
31
31
  var import_framework_utils5 = require("@meridianjs/framework-utils");
32
+ var import_crypto = require("crypto");
32
33
 
33
34
  // src/models/project.ts
34
35
  var import_framework_utils = require("@meridianjs/framework-utils");
@@ -45,6 +46,7 @@ var Project = import_framework_utils.model.define("project", {
45
46
  /** Denormalized workspace reference — no FK constraint */
46
47
  workspace_id: import_framework_utils.model.text(),
47
48
  owner_id: import_framework_utils.model.text().nullable(),
49
+ share_token: import_framework_utils.model.text().nullable(),
48
50
  /** Arbitrary key/value storage for custom integrations */
49
51
  metadata: import_framework_utils.model.json().nullable()
50
52
  }, [
@@ -169,6 +171,24 @@ var ProjectModuleService = class extends (0, import_framework_utils5.MeridianSer
169
171
  const repo = this.container.resolve("projectStatusRepository");
170
172
  return repo.find({ project_id: projectId }, { orderBy: { position: "ASC" } });
171
173
  }
174
+ /** Generate a random share token and set visibility to "public". */
175
+ async generateShareToken(projectId) {
176
+ const token = (0, import_crypto.randomBytes)(32).toString("hex");
177
+ return this.updateProject(projectId, { share_token: token, visibility: "public" });
178
+ }
179
+ /** Remove the share token and set visibility back to "private". */
180
+ async revokeShareToken(projectId) {
181
+ return this.updateProject(projectId, { share_token: null, visibility: "private" });
182
+ }
183
+ /** Find a project by share token. Returns null if not found or not public. */
184
+ async retrieveProjectByShareToken(token) {
185
+ const repo = this.container.resolve("projectRepository");
186
+ try {
187
+ return await repo.findOneOrFail({ share_token: token, visibility: "public" });
188
+ } catch {
189
+ return null;
190
+ }
191
+ }
172
192
  /** Update position field for each status to match the provided orderedIds index. */
173
193
  async reorderStatuses(projectId, orderedIds) {
174
194
  const repo = this.container.resolve("projectStatusRepository");
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { Module } from "@meridianjs/framework-utils";
3
3
 
4
4
  // src/service.ts
5
5
  import { MeridianService } from "@meridianjs/framework-utils";
6
+ import { randomBytes } from "crypto";
6
7
 
7
8
  // src/models/project.ts
8
9
  import { model } from "@meridianjs/framework-utils";
@@ -19,6 +20,7 @@ var Project = model.define("project", {
19
20
  /** Denormalized workspace reference — no FK constraint */
20
21
  workspace_id: model.text(),
21
22
  owner_id: model.text().nullable(),
23
+ share_token: model.text().nullable(),
22
24
  /** Arbitrary key/value storage for custom integrations */
23
25
  metadata: model.json().nullable()
24
26
  }, [
@@ -143,6 +145,24 @@ var ProjectModuleService = class extends MeridianService({
143
145
  const repo = this.container.resolve("projectStatusRepository");
144
146
  return repo.find({ project_id: projectId }, { orderBy: { position: "ASC" } });
145
147
  }
148
+ /** Generate a random share token and set visibility to "public". */
149
+ async generateShareToken(projectId) {
150
+ const token = randomBytes(32).toString("hex");
151
+ return this.updateProject(projectId, { share_token: token, visibility: "public" });
152
+ }
153
+ /** Remove the share token and set visibility back to "private". */
154
+ async revokeShareToken(projectId) {
155
+ return this.updateProject(projectId, { share_token: null, visibility: "private" });
156
+ }
157
+ /** Find a project by share token. Returns null if not found or not public. */
158
+ async retrieveProjectByShareToken(token) {
159
+ const repo = this.container.resolve("projectRepository");
160
+ try {
161
+ return await repo.findOneOrFail({ share_token: token, visibility: "public" });
162
+ } catch {
163
+ return null;
164
+ }
165
+ }
146
166
  /** Update position field for each status to match the provided orderedIds index. */
147
167
  async reorderStatuses(projectId, orderedIds) {
148
168
  const repo = this.container.resolve("projectStatusRepository");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meridianjs/project",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Meridian project module — Project, Label, Milestone domain models",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",