@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.
- package/CHANGELOG.md +23 -1
- package/README.md +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -11
- package/dist/cli.js.map +1 -1
- package/dist/init/init.d.ts +8 -0
- package/dist/init/init.d.ts.map +1 -1
- package/dist/init/init.js +268 -16
- package/dist/init/init.js.map +1 -1
- package/dist/init/templates/dotnet/Core/ConnectorCore.cs.ejs +11 -8
- package/dist/init/templates/dotnet/Core/IItemPayload.cs.ejs +23 -0
- package/dist/init/templates/dotnet/Core/Principal.cs.ejs +41 -26
- package/dist/init/templates/dotnet/Datasource/CsvItemSource.cs.ejs +1 -1
- package/dist/init/templates/dotnet/Datasource/IItemSource.cs.ejs +2 -4
- package/dist/init/templates/dotnet/Generated/ItemPayload.cs.ejs +10 -0
- package/dist/init/templates/dotnet/Program.commandline.cs.ejs +4 -3
- package/dist/init/templates/dotnet/README.md.ejs +1 -1
- package/dist/init/templates/rest/create-connection.http.ejs +10 -0
- package/dist/init/templates/rest/ingest-item.http.ejs +11 -0
- package/dist/init/templates/rest/patch-schema.http.ejs +10 -0
- package/dist/init/templates/rest/profile-source.http.ejs +34 -0
- package/dist/init/templates/ts/AGENTS.md.ejs +1 -1
- package/dist/init/templates/ts/README.md.ejs +1 -1
- package/dist/init/templates/ts/src/core/connectorCore.ts.ejs +1 -1
- package/dist/init/templates/ts/src/core/principal.ts.ejs +7 -5
- package/dist/init/templates/ts/src/datasource/csvItemSource.ts.ejs +1 -1
- package/dist/init/templates/ts/src/datasource/itemSource.ts.ejs +2 -7
- package/dist/init/templates/ts/src/generated/itemPayload.ts.ejs +3 -1
- 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
|
|
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
|
|
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
|
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Principal representation for external connector schema properties.
|
|
3
3
|
*/
|
|
4
4
|
export type Principal = {
|
|
5
|
-
"@odata.type": "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
|
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
|
|