{"id":23854767,"url":"https://github.com/Service-Soft/lbx-change-sets","last_synced_at":"2025-09-08T01:32:18.739Z","repository":{"id":166614651,"uuid":"640889967","full_name":"Service-Soft/lbx-change-sets","owner":"Service-Soft","description":"This package helps you to track changes made on your entities automatically using a base repository class to extend from","archived":false,"fork":false,"pushed_at":"2025-07-30T12:17:43.000Z","size":1040,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-07-30T14:53:18.526Z","etag":null,"topics":["change-set","change-tracking","loopback","loopback-extension","restore","rollback","soft-delete"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Service-Soft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.MD","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-15T10:44:25.000Z","updated_at":"2025-07-30T12:15:32.000Z","dependencies_parsed_at":"2025-01-03T00:03:23.373Z","dependency_job_id":"9c597aac-e9a2-4438-a910-d5e06c11bcc1","html_url":"https://github.com/Service-Soft/lbx-change-sets","commit_stats":null,"previous_names":["service-soft/lbx-change-sets"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Service-Soft/lbx-change-sets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Service-Soft%2Flbx-change-sets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Service-Soft%2Flbx-change-sets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Service-Soft%2Flbx-change-sets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Service-Soft%2Flbx-change-sets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Service-Soft","download_url":"https://codeload.github.com/Service-Soft/lbx-change-sets/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Service-Soft%2Flbx-change-sets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274121922,"owners_count":25225801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-set","change-tracking","loopback","loopback-extension","restore","rollback","soft-delete"],"created_at":"2025-01-03T00:01:37.986Z","updated_at":"2025-09-08T01:32:18.418Z","avatar_url":"https://github.com/Service-Soft.png","language":"TypeScript","funding_links":[],"categories":["Development Utilities"],"sub_categories":["Runtime"],"readme":"# lbx-change-sets\n\nThis package helps you to track changes made on your entities automatically using a base repository class to extend from:\n\n- Automatically generate change sets containing information about WHO, WHEN and WHAT was changed on your entities.\n- Be able to rollback a single or multiple entities to the state of a specified change set or date. (The reset gets also tracked)\n- Be able to \"softly\" delete entities, which have a delete flag on them.\n- Be able to restore a single or multiple \"softly\" deleted entities.\n\n# Usage\n\n## Register the component\n\nThe minimum required code changes to use the library to its full extend is simply registering it in the `application.ts` constructor:\n\n```ts\nimport { ChangeRepository, ChangeSetRepository, LbxChangeSetsComponent } from 'lbx-change-sets';\n\n//...\nthis.component(LbxChangeSetsComponent);\nthis.repository(ChangeRepository);\nthis.repository(ChangeSetRepository);\n//...\n```\n\n## Change Set\n### Create an entity that should use change sets\nAll entities that should make use of the change set functionality need to extend `ChangeSetEntity`:\n\n```ts\nimport { ChangeSetEntity } from 'lbx-change-sets';\n// ...\n@model()\nexport class TestChangeSetEntity extends ChangeSetEntity {\n    @property({\n        type: 'string',\n        required: true\n    })\n    firstName: string;\n\n    @property({\n        type: 'string',\n        required: true\n    })\n    lastName: string;\n\n    constructor(data?: Partial\u003cTestChangeSetEntity\u003e) {\n        super(data);\n    }\n}\n```\n### Create the repository for that entity\nThe repository needs to extend `CrudChangeSetRepository`:\n```ts\nimport { CrudChangeSetRepository } from 'lbx-change-sets';\n// ...\nexport class TestChangeSetEntityRepository extends CrudChangeSetRepository\u003c\n    TestChangeSetEntity,\n    typeof TestChangeSetEntity.prototype.id,\n    TestRelations\n\u003e {\n    constructor(\n        @inject('datasources.db')\n        dataSource: DbDataSource,\n        @repository.getter('ChangeSetRepository')\n        changeSetRepositoryGetter: Getter\u003cChangeSetRepository\u003e,\n        @repository(ChangeRepository)\n        changeRepository: ChangeRepository,\n        @repository(ChangeSetRepository)\n        changeSetRepository: ChangeSetRepository,\n        @inject.getter(SecurityBindings.USER)\n        getUserProfile: Getter\u003cUserProfile\u003e\n    ) {\n        super(TestChangeSetEntity, dataSource, changeSetRepositoryGetter, changeRepository, changeSetRepository, getUserProfile);\n    }\n}\n```\n\n### Enjoy!\nThat's it. Whenever you user the default actions of the repository like \"create\" or \"updateById\" a change set will be generated automatically.\n\nIf you use transactions they will be used to guarantee that change sets are only generated when the base operation worked.\n\n\u003e INFO: If you have complex relations that should be tracked or rolled back you will probably need to override the corresponding methods.\n\n### Get change sets\nAll existing change sets are available via the normal `@hasMany` property \"changeSets\" on your entity and repository. You can however also get them via the `ChangeSetRepository` and `ChangeRepository`.\n\n### Rollback\nTo rollback you can simply call the methods `rollback[ToDate | ToChangeSet...]` on your repository.\n\n### Exclude properties from change set creation\nIf you have some properties that you don't want to have in your change sets, you can exlude them by overriding the `keysToExcludeFromChangeSets` array in your repository. By default this already doesn't track the entities id.\n\n## Change Set \u0026 Soft Delete\nIf you want to use the soft delete features aswell, you can basically follow the same steps above but extend from `ChangeSetSoftDeleteEntity` and `CrudChangeSetSoftDeleteRepository`.\n\nThey provide the same functionality mentionend above and some more:\n\n### soft delete\nTo softly delete a single or multiple entities you can use the respoitories `softDelete[ById | All...]` methods.\n\n### restore\nTo softly delete a single or multiple entities you can use the respoitories `restore[ById | All...]` methods.\n\n### convenience methods\nBecause most times you probably want to only return or update entities that aren't deleted, the repository provides some convenience methods for that:\n- findNonDeleted: `find`, but limited to not deleted entities\n- findDeleted: `find`, but limited to deleted entities\n- updateAllNonDeleted: `updateAll`, but limited to not deleted entities\n- updateAllDeleted: `updateAll`, but limited to deleted entities\n- rollbackAllNonDeletedToDate: `rollbackAllToDate`, but limited to not deleted entities\n- rollbackAllDeletedToDate: `rollbackAllToDate`, but limited to deleted entities\n- deleteAllDeleted: `deleteAll`, but limited to deleted entities","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FService-Soft%2Flbx-change-sets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FService-Soft%2Flbx-change-sets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FService-Soft%2Flbx-change-sets/lists"}