@powerhousedao/contributor-billing 0.1.39 → 0.1.40

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 +1 @@
1
- {"version":3,"file":"AccountForm.d.ts","sourceRoot":"","sources":["../../../../editors/accounts-editor/components/AccountForm.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,uDAAuD,CAAC;AAE/D,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,EAAE;QACjB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,gBAAgB,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,YAAY,CAAC,EAAE,qBAAqB,CAAC;KACtC,KAAK,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAqP5E"}
1
+ {"version":3,"file":"AccountForm.d.ts","sourceRoot":"","sources":["../../../../editors/accounts-editor/components/AccountForm.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,uDAAuD,CAAC;AAE/D,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,EAAE;QACjB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,gBAAgB,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,YAAY,CAAC,EAAE,qBAAqB,CAAC;KACtC,KAAK,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAiQ5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/budget-statements/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA0E5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA+LxE,CAAC"}
1
+ {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/budget-statements/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA0E5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA0RxE,CAAC"}
@@ -62,31 +62,96 @@ export const getResolvers = (subgraph) => {
62
62
  return {
63
63
  Query: {
64
64
  budgetStatements: async (_, args) => {
65
- const { teamId } = args.filter || {};
65
+ const { teamId, networkSlug } = args.filter || {};
66
66
  const drives = await reactor.getDrives();
67
- // Step 1: Collect all documents from all drives
67
+ // Step 1: Collect all documents from all drives (or filtered by networkSlug)
68
68
  const snapshotReportDocs = [];
69
69
  const expenseReportDocs = [];
70
70
  const accountTransactionsDocs = new Map();
71
71
  const builderProfileDocs = new Map();
72
- for (const driveId of drives) {
72
+ // If networkSlug is provided, find the network drive and get valid builder PHIDs
73
+ let allowedBuilderPhids = null;
74
+ if (networkSlug) {
75
+ const targetNetworkSlug = networkSlug.toLowerCase().trim();
76
+ // Find the network drive matching the slug
77
+ for (const driveId of drives) {
78
+ try {
79
+ const docIds = await reactor.getDocuments(driveId);
80
+ const docs = await Promise.all(docIds.map(async (docId) => {
81
+ try {
82
+ return await reactor.getDocument(docId);
83
+ }
84
+ catch {
85
+ return null;
86
+ }
87
+ }));
88
+ const networkDoc = docs.find((doc) => {
89
+ if (!doc ||
90
+ doc.header.documentType !== "powerhouse/network-profile")
91
+ return false;
92
+ const state = doc.state
93
+ .global;
94
+ if (!state?.name)
95
+ return false;
96
+ const slug = state.name
97
+ .toLowerCase()
98
+ .trim()
99
+ .split(/\s+/)
100
+ .join("-");
101
+ return slug === targetNetworkSlug;
102
+ });
103
+ if (networkDoc) {
104
+ // Get the builders list from this drive
105
+ const buildersDoc = docs.find((doc) => doc && doc.header.documentType === "powerhouse/builders");
106
+ if (buildersDoc) {
107
+ const state = buildersDoc.state.global;
108
+ if (Array.isArray(state?.builders)) {
109
+ allowedBuilderPhids = new Set(state.builders.filter((id) => typeof id === "string"));
110
+ }
111
+ }
112
+ break;
113
+ }
114
+ }
115
+ catch (error) {
116
+ console.warn(`Failed to inspect drive ${driveId}:`, error);
117
+ }
118
+ }
119
+ // If no network found or no builders list, return empty results
120
+ if (!allowedBuilderPhids) {
121
+ return [];
122
+ }
123
+ }
124
+ // Always scan all drives - reports may be in different drives than the network drive
125
+ // Filter is applied by ownerId matching allowedBuilderPhids
126
+ const drivesToScan = drives;
127
+ for (const driveId of drivesToScan) {
73
128
  const docsIds = await reactor.getDocuments(driveId);
74
129
  const docs = await Promise.all(docsIds.map(async (docId) => reactor.getDocument(docId)));
75
130
  for (const doc of docs) {
76
131
  const docType = doc.header.documentType;
77
132
  if (docType === "powerhouse/snapshot-report") {
78
133
  const snapshotDoc = doc;
79
- // If teamId filter is provided, only include matching reports
80
- if (!teamId || snapshotDoc.state.global.ownerId === teamId) {
81
- snapshotReportDocs.push(snapshotDoc);
82
- }
134
+ const ownerId = snapshotDoc.state.global.ownerId;
135
+ // Apply filters: teamId takes precedence, then networkSlug (via allowedBuilderPhids)
136
+ if (teamId && ownerId !== teamId)
137
+ continue;
138
+ if (allowedBuilderPhids &&
139
+ ownerId &&
140
+ !allowedBuilderPhids.has(ownerId))
141
+ continue;
142
+ snapshotReportDocs.push(snapshotDoc);
83
143
  }
84
144
  else if (docType === "powerhouse/expense-report") {
85
145
  const expenseDoc = doc;
86
- // If teamId filter is provided, only include matching reports
87
- if (!teamId || expenseDoc.state.global.ownerId === teamId) {
88
- expenseReportDocs.push(expenseDoc);
89
- }
146
+ const ownerId = expenseDoc.state.global.ownerId;
147
+ // Apply filters: teamId takes precedence, then networkSlug (via allowedBuilderPhids)
148
+ if (teamId && ownerId !== teamId)
149
+ continue;
150
+ if (allowedBuilderPhids &&
151
+ ownerId &&
152
+ !allowedBuilderPhids.has(ownerId))
153
+ continue;
154
+ expenseReportDocs.push(expenseDoc);
90
155
  }
91
156
  else if (docType === "powerhouse/account-transactions") {
92
157
  const txDoc = doc;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/budget-statements/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAiIpB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/budget-statements/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAkIpB,CAAC"}
@@ -8,7 +8,8 @@ export const schema = gql `
8
8
  }
9
9
 
10
10
  input budgetStatementsFilter {
11
- teamId: PHID!
11
+ teamId: PHID
12
+ networkSlug: String
12
13
  }
13
14
 
14
15
  type BudgetStatement {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/contributor-billing",
3
3
  "description": "Document models that help contributors of open organisations get paid anonymously for their work on a monthly basis.",
4
- "version": "0.1.39",
4
+ "version": "0.1.40",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [