@wictorwilen/cocogen 1.0.21 → 1.0.24

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 (29) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +1 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +23 -11
  5. package/dist/cli.js.map +1 -1
  6. package/dist/init/init.d.ts +8 -0
  7. package/dist/init/init.d.ts.map +1 -1
  8. package/dist/init/init.js +268 -16
  9. package/dist/init/init.js.map +1 -1
  10. package/dist/init/templates/dotnet/Core/ConnectorCore.cs.ejs +11 -8
  11. package/dist/init/templates/dotnet/Core/IItemPayload.cs.ejs +23 -0
  12. package/dist/init/templates/dotnet/Core/Principal.cs.ejs +41 -26
  13. package/dist/init/templates/dotnet/Datasource/CsvItemSource.cs.ejs +1 -1
  14. package/dist/init/templates/dotnet/Datasource/IItemSource.cs.ejs +2 -4
  15. package/dist/init/templates/dotnet/Generated/ItemPayload.cs.ejs +10 -0
  16. package/dist/init/templates/dotnet/Program.commandline.cs.ejs +4 -3
  17. package/dist/init/templates/dotnet/README.md.ejs +1 -1
  18. package/dist/init/templates/rest/create-connection.http.ejs +10 -0
  19. package/dist/init/templates/rest/ingest-item.http.ejs +11 -0
  20. package/dist/init/templates/rest/patch-schema.http.ejs +10 -0
  21. package/dist/init/templates/rest/profile-source.http.ejs +34 -0
  22. package/dist/init/templates/ts/AGENTS.md.ejs +1 -1
  23. package/dist/init/templates/ts/README.md.ejs +1 -1
  24. package/dist/init/templates/ts/src/core/connectorCore.ts.ejs +1 -1
  25. package/dist/init/templates/ts/src/core/principal.ts.ejs +7 -5
  26. package/dist/init/templates/ts/src/datasource/csvItemSource.ts.ejs +1 -1
  27. package/dist/init/templates/ts/src/datasource/itemSource.ts.ejs +2 -7
  28. package/dist/init/templates/ts/src/generated/itemPayload.ts.ejs +3 -1
  29. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ @graphBaseUrl = <%= graphBaseUrl %>
2
+ @connectionId = <%= connectionId %>
3
+ @token = {{token}}
4
+
5
+ ### Patch schema
6
+ PATCH {{graphBaseUrl}}/external/connections/{{connectionId}}/schema
7
+ Authorization: Bearer {{token}}
8
+ Content-Type: application/json
9
+
10
+ <%- schemaPayloadJson %>
@@ -0,0 +1,34 @@
1
+ @graphBaseUrl = <%= graphBaseUrl %>
2
+ @connectionId = <%= connectionId %>
3
+ @token = {{token}}
4
+ @profileSourceWebUrl = <%= profileSourceWebUrl %>
5
+ @profileSourceDisplayName = <%= profileSourceDisplayName %>
6
+ @profileSourcePriority = <%= profileSourcePriority %>
7
+ @sourceUrl = {{graphBaseUrl}}/admin/people/profileSources(sourceId='{{connectionId}}')
8
+ @settingsId = {{settingsId}}
9
+
10
+ ### Register profile source (people connectors)
11
+ POST {{graphBaseUrl}}/admin/people/profileSources
12
+ Authorization: Bearer {{token}}
13
+ Content-Type: application/json
14
+
15
+ {
16
+ "sourceId": "{{connectionId}}",
17
+ "displayName": "{{profileSourceDisplayName}}",
18
+ "webUrl": "{{profileSourceWebUrl}}"
19
+ }
20
+
21
+ ### List profile property settings
22
+ GET {{graphBaseUrl}}/admin/people/profilePropertySettings
23
+ Authorization: Bearer {{token}}
24
+
25
+ ### Update profile source precedence (set @settingsId after listing)
26
+ PATCH {{graphBaseUrl}}/admin/people/profilePropertySettings/{{settingsId}}
27
+ Authorization: Bearer {{token}}
28
+ Content-Type: application/json
29
+
30
+ {
31
+ "prioritizedSourceUrls": [
32
+ "{{sourceUrl}}"
33
+ ]
34
+ }
@@ -16,5 +16,5 @@ Only `src/<%= schemaFolderName %>/**` is overwritten by `cocogen update`.
16
16
  Edit `src/<%= schemaFolderName %>/propertyTransform.ts` (safe file). The generated base lives in `src/<%= schemaFolderName %>/propertyTransformBase.ts`.
17
17
 
18
18
  ## Switch datasource / backend
19
- 1) Implement `ItemSource` in `src/datasource`.
19
+ 1) Implement `ItemSource<<%= itemTypeName %>>` in `src/datasource`.
20
20
  2) Update `src/cli.ts` to use your source instead of `CsvItemSource`.
@@ -49,7 +49,7 @@ Use `npm run ingest --` with:
49
49
  Note: `--dry-run` does not require CONNECTION_ID, but you still need it for real ingestion.
50
50
 
51
51
  ## Switching from CSV to another datasource
52
- 1) Implement `ItemSource` in `src/datasource`.
52
+ 1) Implement `ItemSource<<%= itemTypeName %>>` in `src/datasource`.
53
53
  2) If your source yields raw records, map them to `<%= itemTypeName %>` using `fromRow`-style logic.
54
54
  3) Update `src/cli.ts` to instantiate your new source instead of `CsvItemSource`.
55
55
 
@@ -28,7 +28,7 @@ export type ProvisionOptions = {
28
28
  };
29
29
 
30
30
  export type IngestOptions<Item> = {
31
- source: ItemSource;
31
+ source: ItemSource<Item>;
32
32
  connectionId: string;
33
33
  dryRun?: boolean;
34
34
  limit?: number;
@@ -2,11 +2,13 @@
2
2
  * Principal representation for external connector schema properties.
3
3
  */
4
4
  export type Principal = {
5
- "@odata.type": "#microsoft.graph.externalConnectors.principal";
6
- id?: string;
7
- type?: string;
8
- displayName?: string;
9
- userPrincipalName?: string;
5
+ "@odata.type": "microsoft.graph.externalConnectors.principal";
6
+ externalName?: string;
7
+ externalId?: string;
8
+ entraDisplayName?: string;
9
+ entraId?: string;
10
+ email?: string;
11
+ upn?: string;
10
12
  tenantId?: string;
11
13
  [key: string]: string | undefined;
12
14
  };
@@ -11,7 +11,7 @@ import { fromRow } from "../<%= schemaFolderName %>/fromRow.js";
11
11
  /**
12
12
  * CSV-based datasource (default). Replace with your own ItemSource as needed.
13
13
  */
14
- export class CsvItemSource implements ItemSource {
14
+ export class CsvItemSource implements ItemSource<<%= itemTypeName %>> {
15
15
  constructor(private readonly filePath: string) {}
16
16
 
17
17
  /**
@@ -1,15 +1,10 @@
1
- /**
2
- * Datasource contract for producing items to ingest.
3
- */
4
- import type { <%= itemTypeName %> } from "../<%= schemaFolderName %>/model.js";
5
-
6
1
  /**
7
2
  * Contract for any datasource that yields items for ingestion.
8
3
  * Implement this interface to swap the default datasource for an API, database, or other system.
9
4
  */
10
- export interface ItemSource {
5
+ export interface ItemSource<TItem> {
11
6
  /**
12
7
  * Return items as an async iterable (streaming preferred).
13
8
  */
14
- getItems(): AsyncIterable<<%= itemTypeName %>>;
9
+ getItems(): AsyncIterable<TItem>;
15
10
  }
@@ -19,7 +19,9 @@ const cleanPrincipalCollection = (
19
19
  values: Array<Record<string, unknown>> | null | undefined
20
20
  ): Array<Record<string, unknown>> | null | undefined => {
21
21
  if (!values) return values;
22
- return values.map((value) => cleanPrincipal(value));
22
+ return values
23
+ .filter((value): value is Record<string, unknown> => Boolean(value))
24
+ .map((value) => cleanPrincipal(value) ?? value);
23
25
  };
24
26
  <% } -%>
25
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wictorwilen/cocogen",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "TypeSpec-driven Microsoft Copilot connector generator",
5
5
  "license": "MIT",
6
6
  "author": "Wictor Wilén <wictor@wictorwilen.se>",